...
configuration of the images folder
REST API configuration
Database
This guide does not cover the database setup. Both PostgreSQL and Microsoft SQL Server are supported here.
...
The REST API requires a Microsoft database!
First, go to oi
and clone the REST API repository:
Code Block |
---|
cd /oi
git clone https://github.com/openimis/rest_api_c-sharp
cd rest_api_c-sharp |
At this stage, you should be on the main
branch. ⚠️ Currently (4 May 2023), there are some issues that must be fixed on the main
branch, so you should go to the fix/docker_compose
until it has been merged into main
: git switch fix/docker_compose
.
Before starting the REST API, you will need to edit the docker-compose
and Dockerfile
files with the database information.
Here is a sample docker-compose
file. Replace the database values in the environment
section:
Code Block |
---|
version: '2.4'
services:
restapi:
build:
context: ./
args:
BUILD-FLAVOUR: ${BUILD-FLAVOUR:-Release}
environment:
- DB_HOST=Server
- DB_NAME=IMIS
- DB_USER=IMISuser
- DB_PASSWORD=IMISuser@1234
- DB_PORT=1433
ports:
- 8080:80
volumes:
- ./OpenImis.RestApi/config:/app/config
- ./OpenImis.RestApi/logs:/app/log
- ./OpenImis.RestApi/Certificates:/app/wwwRoot/Certificates
- ./photos:/app/photos
- ./Escape:/app/Escape
- ./FromPhone:/app/FromPhone
restart: always
|
Here is a sample Dockerfile
file. Replace the ENV database values:
Code Block |
---|
FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build-env
WORKDIR /app
COPY /OpenImis.RestApi/*.csproj ./
RUN dotnet restore
ARG BUILD-FLAVOUR=Release
COPY . ./
RUN dotnet publish OpenImis.RestApi/OpenImis.RestApi.csproj -c $BUILD-FLAVOUR -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1
WORKDIR /app
ENV DB_HOST=Server
ENV DB_NAME=IMIS
ENV DB_USER=IMISuser
ENV DB_PASSWORD=IMISuser@1234
# copy appsettings templates
COPY ./OpenImis.RestApi/config/appsettings.Production.json.dist /app/tpl/
COPY ./OpenImis.RestApi/config/appsettings.json /app/config/
COPY ./scripts/entrypoint.sh /app/
RUN chmod a+x /app/entrypoint.sh
COPY --from=build-env /app/OpenImis.RestApi/out .
RUN echo 'deb http://archive.debian.org/debian/ stretch main' > /etc/apt/sources.list \
&& echo 'deb http://archive.debian.org/debian-security/ stretch/updates main' >> /etc/apt/sources.list \
&& apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install gettext -y \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT /app/entrypoint.sh
|
Then, you can start the Docker service:
Code Block |
---|
docker-compose up -d |
Once the container has finished building and has started, you can check that the REST API is properly working:
First, you can type
docker ps
. In theSTATUS
column, you should see something similar toUp xx minutes
.Then you can access the REST API and see if you see any data fetched from the database, for instance by accessing the following page: <openIMIS-URL>/rest/api/claim/Controls
Page Tree | ||
---|---|---|
|
Previous step: MO1.1 Install openIMIS using Docker | Next step: |
...