Skip to content

Commit

Permalink
Finish release/v1.1.0
Browse files Browse the repository at this point in the history
Docker on windows
  • Loading branch information
dragos-dobre authored Apr 28, 2020
2 parents 7a7e880 + 7e9cb7b commit 17d4dfe
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 40 deletions.
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This repository provides a dockerized openIMIS (all components) as a quick setup for development, testing or demoing.

Please look for the direction on the openIMIS Wiki: https://openimis.atlassian.net/wiki/spaces/OP/pages/963182705/MO1.1+Install+the+modular+openIMIS+using+Docker

The docker-compose currently only contains the openIMIS database, backend, frontend and gateway components. It will be completed as the other components are added to the platform (batch platform,...)

| Disclaimer : NOT FOR PRODUCTION USE |
Expand All @@ -10,10 +12,16 @@

In case of troubles, please consult/contact our service desk via our [ticketing site](https://openimis.atlassian.net/servicedesk/customer).

#Prerequisit
- Windows 10 or Windows server 2016
- Docker installed and in Windows container mode
-
In case of troubles, please consult/contact our service desk via our [ticketing site](https://openimis.atlassian.net/servicedesk/customer).

# First startup
First startup is special since it will create the necessary docker images and containers to run openIMIS.
To build necessary, docker images, docker-compose relies on ***local*** docker files.
In order to build these images, you need to clone, next to `openimis-dist_dkr/` the following github repository:
In order to build these images, you need to clone, next to `openimis-dist_dkr/` the following github repository:branch:
* openimis-db_dkr
* openimis-be_py
* openimis-fe_js
Expand All @@ -27,37 +35,32 @@ git clone https://github.com/openimis/openimis-fe_js.git
git clone https://github.com/openimis/openimis-gateway_dkr.git
```

From within `openimis-dist_dkr/` directory:
From within `openimis-dist_dkr/windows` directory:
* create a `.env` file, providing the following variables:
```
#DB_SQL_SCRIPT=<URL pointing to the SQL script>
#ACCEPT_EULA=<must put Y but it means you accept Microsoft EULA for the MSSQL database container>
DB_HOST=<your database host, or db to use the demo docker 'db' service>
DB_PORT=<your database port on the host, 1433 if you use the demo docker 'db' service>
DB_SQL_SCRIPT=<URL pointing to the SQL script>
ACCEPT_EULA=<must put Y but it means you accept Microsoft EULA for the MSSQL database container>
DB_HOST=database
DB_PORT=1433
DB_NAME=<your database name, imis if you use the demo docker 'db' service>
DB_USER=<your database user, sa if you use the demo docker 'db' service >
DB_PASSWORD=<your database password, generate one if you use the demo docker 'db' service>
NEW_OPENIMIS_HOST=<(sub)domain under which the (new) openIMIS will be served (e.g. openimis.domaine) >
LEGACY_OPENIMIS_HOST=<(sub)domain under which legacy openIMIS is served (e.g. demo.openimis.org) >
LEGACY_OPENIMIS_HOST=frontend
```

* If you use the demo docker 'db' service:
* choose the SQL script to create/restore the database. Reference models are provided in [database_ms_sqlserver](https://github.com/openimis/database_ms_sqlserver) github. Example:
* Empty database: `https://github.com/openimis/database_ms_sqlserver/raw/master/Empty%20databases/openIMIS_ONLINE.sql`
* Demo database: `https://github.com/openimis/database_ms_sqlserver/raw/develop/Demo%20database/openIMIS_demo_1.3.0.sql`
* Empty database: `https://github.com/openimis/database_ms_sqlserver/blob/master/Empty%20databases/openIMIS_ONLINE.sql?raw=true`
* Demo database: `https://github.com/openimis/database_ms_sqlserver/blob/master/Demo%20database/openIMIS_demo_ONLINE.sql?raw=true`
* build and start the database docker image: `docker-compose up db`
(note: use --force-recreate if you already created the image but want to change the password)
* create the imis database into the container:
* `docker container ls` and spot the line (CONTAINER ID) with `openimis-db` IMAGE name
* `docker exec <CONTAINER ID> /create_database.sh`
* build and start the gateway (and backend) docker image: `docker-compose up gateway`
* `docker exec <CONTAINER ID> /create_database.bat`
* create the imis users
* `docker exec <CONTAINER ID> /create_user_db.bat`
* build and start rest of the container (and backend) docker image: `docker-compose up`
(note: at each start, openIMIS will apply the necessary database migrations to update the database scheme)
* (if your are not working on localhost) register a letsencrypt certificate for your openIMIS gateway
* list running containers and spot the gateway: `docker container ls` (the gateway should be named `openimis-gateway`)
* connect to the gateway: `docker exec -it <CONTAINER ID> /bin/sh` (sh and not bash)
* issue the command `install-certificate.sh` ... and follow the setup wizzard (provide contact address,
* in case you are using your own computer and localhost NEW_OPENIMIS_HOST, running the lets encrypt script will activate the SSL but the SSL generation will fail, to solve this you can use self signed certificates
`openssl req -sha256 -newkey rsa:4096 -nodes -keyout privkey.pem -x509 -days 730 -out /etc/letsencrypt/live/localhost/fullchain.pem`
* register your openIMIS superuser in the gateway:
* list running containers and spot the gateway: `docker container ls` (the gateway should be named `openimis-gateway`)
* connect to the gateway: `docker exec -it <CONTAINER ID> /bin/sh` (sh and not bash)
Expand All @@ -66,13 +69,8 @@ From within `openimis-dist_dkr/` directory:
Notes:
* same procedure (add-user.sh) must be followed to add external applications accesses
* in `/script`, there are also `remove-user.sh`and `update-user.sh`
* If connecting to brand new database, register your openIMIS superuser:
* list running containers and spot the backend: `docker container ls` (the gateway should be named `openimis-backend`)
* connect to the gateway: `docker exec -it <CONTAINER ID> /bin/bash` (bash and not sh this time)
* you should be in /openimis-be/openIMIS directory, if not, just `cd /openimis-be/openIMIS`)
* register your openIMIS superuser: `python manage.py createsuperuser` (and follow instructions)

# stop /start
From within `openimis-dist_dkr/` directory:
From within `openimis-dist_dkr/windows` directory:
To stop all docker containers: `docker-compose stop`
To (re-)start all docker containers: `docker-compose start`
40 changes: 24 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
version: "3"
version: "2.4"

services:
# db:
# container_name: openimis-db
# build:
# context: ../openimis-db_dkr
# args:
# - ACCEPT_EULA=${ACCEPT_EULA}
# - SA_PASSWORD=${DB_PASSWORD}
# - SQL_SCRIPT_URL=${DB_SQL_SCRIPT}
# networks:
# - openimis-net
# db:
# container_name: openimis-db
# build:
# context: ../openimis-db_dkr
# args:
# - ACCEPT_EULA=${ACCEPT_EULA}
# - SA_PASSWORD=${DB_PASSWORD}
# - SQL_SCRIPT_URL=${DB_SQL_SCRIPT}
# networks:
# - openimis-net
## WARNING:
## exposing the database port outside the openimis-net network
## may lead to security issue (depending on your network topology)
# ports:
# - 1433:1433
backend:
platform: linux
container_name: openimis-backend
build: ../openimis-be_py
command: start
Expand Down Expand Up @@ -89,25 +90,32 @@ services:
# depends_on:
# - db
frontend:
platform: linux
container_name: openimis-frontend
build: ../openimis-fe_js
build:
context: ../openimis-fe_js
command: serve -s build
environment:
- REACT_APP_API_URL=/iapi
- NEW_OPENIMIS_HOST=${NEW_OPENIMIS_HOST}
- LEGACY_OPENIMIS_HOST=${LEGACY_OPENIMIS_HOST}
networks:
- openimis-net
# volumes:
# - ../conf:/conf
## WARNING:
## exposing the frontend port outside the openimis-net network
## may lead to security issue (depending on your network topology)
# ports:
# - 5000:5000
gateway:
platform: linux
container_name: openimis-gateway
build:
context: ../openimis-gateway_dkr
args:
- NEW_OPENIMIS_HOST=${NEW_OPENIMIS_HOST}
- LEGACY_OPENIMIS_HOST=${LEGACY_OPENIMIS_HOST}
environment:
- NEW_OPENIMIS_HOST=${NEW_OPENIMIS_HOST}
- LEGACY_OPENIMIS_HOST=${LEGACY_OPENIMIS_HOST}
volumes:
- ../conf:/conf
networks:
Expand All @@ -120,4 +128,4 @@ services:
- ibackend
- frontend
networks:
openimis-net:
openimis-net:
156 changes: 156 additions & 0 deletions windows/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
version: "2.4"

services:
# in such context the database will not have enough memory, http://www.teamfoundation.co.za/2018/05/07/docker-linux-and-windows-event-more-3-from-containers-lcow/
database:
platform: windows
container_name: openimis-db
build:
context: ../../openimis-db_dkr
dockerfile: Dockerfile_win
args:
- ACCEPT_EULA=${ACCEPT_EULA}
- SA_PASSWORD=${DB_PASSWORD}
- SQL_SCRIPT_URL=${DB_SQL_SCRIPT}
environment:
- ACCEPT_EULA=${ACCEPT_EULA}
- SA_PASSWORD=${DB_PASSWORD}
- SQL_SCRIPT_URL=${DB_SQL_SCRIPT}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
networks:
- openimis-net
healthcheck:
test: ["CMD","sqlcmd","-U","$DB_USER","-P","$DB_PASSWORD","-d","$DB_NAME","-Q","SELECT 1"]
interval: 30s
## WARNING:
## exposing the database port outside the openimis-net network
## may lead to security issue (depending on your network topology)
ports:
- 1433:1433
backend:
platform: windows
container_name: openimis-backend
build:
context: ../../openimis-be_py
dockerfile: Dockerfile_win
command: start
environment:
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- REMOTE_USER_AUTHENTICATION=True
- SITE_ROOT=api
networks:
- openimis-net
depends_on:
database:
condition: service_healthy
ibackend:
condition: service_healthy
healthcheck:
test: ["CMD","powershell","-Command","/openimis-be/script/healthcheck.ps1"]
interval: 1m
timeout: 5m
## WARNING:
## exposing the backend port outside the openimis-net network
## may lead to security issue (depending on your network topology)
# ports:
# - 8000:8000
## OPTION:
## if you want to ensure the (demo) db is started prior to backend,
## simply add the following dependency
# depends_on:
# - db
# frontend:
# platform: windows
# container_name: openimis-frontend
# build:
# context: ../../openimis-fe_js
# dockerfile: Dockerfile_win
# command: C:\\Users\\ContainerAdministrator\\AppData\\Local\\Yarn\\bin\\serve -s build
# environment:
# - REACT_APP_API_URL=/iapi
# networks:
# - openimis-net
## WARNING:
## exposing the frontend port outside the openimis-net network
## may lead to security issue (depending on your network topology)
# ports:
# - 5000:5000
ibackend:
platform: windows
container_name: openimis-ibackend
build:
context: ../../openimis-be_py
dockerfile: Dockerfile_win
command: start
environment:
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- REMOTE_USER_AUTHENTICATION=True
- SITE_ROOT=iapi
networks:
- openimis-net
ports:
- 8000:8000
depends_on:
database:
condition: service_healthy
healthcheck:
test: ["CMD","powershell","-Command","c:/openimis-be/script/healthcheck.ps1"]
interval: 1m
timeout: 5m
gateway:
platform: windows
container_name: openimis-gateway
build:
context: ../../openimis-gateway_dkr
dockerfile: Dockerfile_win
shm_size: '4gb'
environment:
- NEW_OPENIMIS_HOST=${NEW_OPENIMIS_HOST}
- LEGACY_OPENIMIS_HOST=${LEGACY_OPENIMIS_HOST}
# command:
networks:
- openimis-net
ports:
- 80:80
- 443:443
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_started
ibackend:
condition: service_healthy

# volumes:
# - C:/Users/delcpa/Development/openimis-fe_js/conf:c:/openresty/conf
frontend:
platform: windows
container_name: openimis-frontend
build:
context: ../../openimis-fe_js
dockerfile: Dockerfile_win
shm_size: '4gb'
environment:
- DB_PASS=${DB_PASSWORD}
- DB_HOST=${DB_HOST}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
# volumes:
# - vol_photo_updated:/inetpub/wwwroot/openIMIS/Images/Updated:rw
# - vol_photo_submitted:/inetpub/wwwroot/openIMIS/Images/Submitted:rw
networks:
- openimis-net
# volumes:
# vol_photo_updated:
# vol_photo_submitted:
networks:
openimis-net:

0 comments on commit 17d4dfe

Please sign in to comment.