diff --git a/README.md b/README.md index 6012ec6114..923b8764c6 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,11 @@ From root run ### Using Docker ``` -docker-compose -f docker-compose.yml up -d # for production +docker compose -f docker-compose.yml up -d # for production -docker-compose up -d # for development (NOTE: this does not start the ibf-dashboard) +docker compose up -d # for development (NOTE: this does not start the ibf-dashboard) -docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d # for development (same as previous line) +docker compose -f docker-compose.yml -f docker-compose.override.yml up -d # for development (same as previous line) ``` @@ -89,7 +89,7 @@ For IBF-dashboard Suggestion: load everything through Docker, except IBF-dashboard. This has the benefit that changes in front-end code are immediately reflected, instead of having to rebuild. -- `docker-compose up -d` +- `docker compose up -d` - `cd interfaces/IBF-dashboard` - `npm start` @@ -100,7 +100,7 @@ are connected to a database-server). For setting up a fully working version of t 1. Seed database with initial static data -- `docker-compose exec ibf-api-service npm run seed` +- `docker compose exec ibf-api-service npm run seed` 2. Load initial raster data diff --git a/docker-compose.override.yml b/docker-compose.override.yml index ad40ad013e..0de83a03cd 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -5,9 +5,6 @@ services: command: ['npm', 'run', 'start:dev'] environment: - NODE_ENV=development - volumes: - - 'api_service_node_modules:/home/ibf/api-service/node_modules' - - ./services/API-service:/home/ibf/api-service ports: - 3000:3000 depends_on: @@ -22,14 +19,6 @@ services: ibf-geoserver: ports: - 8081:8080 - volumes: - - ./services/API-service/geoserver-volume/raster-files:/opt/geoserver/data_dir/workspaces/ibf-system/ibf-pipeline - - ./services/API-service/geoserver-volume/geoserver-layers:/opt/geoserver/data_dir/workspaces/ibf-system - - nginx: - volumes: - - ./nginx/conf.d:/etc/nginx/user.conf.d - - ./nginx/letsencrypt:/etc/letsencrypt ibf-local-db: image: postgis/postgis diff --git a/docker-compose.yml b/docker-compose.yml index 269ccf5d54..1d593f26d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: nginx: image: staticfloat/nginx-certbot @@ -13,7 +11,7 @@ services: volumes: - ./nginx/conf.d:/etc/nginx/user.conf.d - ibf-dashboard-root:/var/www/ibf-dashboard - - letsencrypt:/etc/letsencrypt + - ./nginx/letsencrypt:/etc/letsencrypt networks: web-server-network: restart: unless-stopped @@ -49,7 +47,8 @@ services: - TWILIO_WHATSAPP_NUMBER=${TWILIO_WHATSAPP_NUMBER} - NG_API_URL=${NG_API_URL} volumes: - - api-root:/home/ibf/api-service + - 'api_service_node_modules:/home/ibf/api-service/node_modules' + - ./services/API-service:/home/ibf/api-service networks: web-server-network: api-network: @@ -94,8 +93,8 @@ services: - GEOSERVER_ADMIN_PASSWORD=${GEOSERVER_ADMIN_PASSWORD} - JAVA_OPTS="-DALLOW_ENV_PARAMETRIZATION=true" volumes: - - api-geoserver-files:/opt/geoserver/data_dir/workspaces/ibf-system/ibf-pipeline - - api-geoserver-workspace:/opt/geoserver/data_dir/workspaces/ibf-system + - ./services/API-service/geoserver-volume/raster-files:/opt/geoserver/data_dir/workspaces/ibf-system/ibf-pipeline + - ./services/API-service/geoserver-volume/geoserver-layers:/opt/geoserver/data_dir/workspaces/ibf-system - ./.env:/opt/geoserver/data_dir/geoserver-environment.properties networks: web-server-network: @@ -104,26 +103,7 @@ services: volumes: ibf-dashboard-root: - api-root: - driver_opts: - type: bind - device: ./services/API-service - o: bind - api-geoserver-files: - driver_opts: - type: bind - device: ./services/API-service/geoserver-volume/raster-files - o: bind - api-geoserver-workspace: - driver_opts: - type: bind - device: ./services/API-service/geoserver-volume/geoserver-layers - o: bind - letsencrypt: - driver_opts: - type: bind - device: ./nginx/letsencrypt - o: bind + api_service_node_modules: networks: web-server-network: diff --git a/docs/TROUBLESHOOT.md b/docs/TROUBLESHOOT.md index 9e37712483..e7209ffa5f 100644 --- a/docs/TROUBLESHOOT.md +++ b/docs/TROUBLESHOOT.md @@ -22,13 +22,13 @@ Sometimes there is an issue with installing all packages for ibf-api-service. Yo - exit (switch to normal user) - cd /home/ibf-user/IBF-system/services/API-service - npm install -- docker-compose restart ibf-api-service +- docker compose restart ibf-api-service ### 502 Bad Gateway on API-calls/Swagger UI -Sometimes for unknown reasons the API & Swagger are unavailable, while 'docker-compose logs ibf-api-service' tells you that the API is running correctly. +Sometimes for unknown reasons the API & Swagger are unavailable, while 'docker compose logs ibf-api-service' tells you that the API is running correctly. -- On the server run 'docker-compose restart nginx' in this case +- On the server run 'docker compose restart nginx' in this case - which will usually solve it. ### Access to files on server @@ -50,7 +50,7 @@ To check if everything starts up correctly: - All containers mentioned in the docker-compose file /IBF-system/docker-compose.yml should be up and running. Check e.g. via `docker container ls` - Application should load and respond properly on http://localhost:4200 -- Check the logs of `ibf-api-service` via `docker-compose logs -f ibf-api-service`. Is it saying that the Nest application started successfully? +- Check the logs of `ibf-api-service` via `docker compose logs -f ibf-api-service`. Is it saying that the Nest application started successfully? - Can you visit the Swagger UI API documentation on http://localhost:3000/docs and try one of the GET endpoints? ### Problem with existing database @@ -59,14 +59,14 @@ If there is a problem with your existing database schema, you can always try to - Access the database via e.g. DBeaver - Alternatively, access it via commandline using - - `docker-compose exec ibf-local-db bash` + - `docker compose exec ibf-local-db bash` - `psql -U ` - Throw away schema via `drop schema "IBF-app" cascade;` - Recreate schema: `create schema "IBF-app";` - Exit the database again -- Restart the ibf-api-service: `docker-compose restart ibf-api-service` or `docker-compose up -d ibf-api-service` +- Restart the ibf-api-service: `docker compose restart ibf-api-service` or `docker compose up -d ibf-api-service` - This will automatically run migration-scripts upon restart, which involves an "initial migration script" which creates all necessary tables. -- Wait until done. Check via `docker-compose logs -f ibf-api-service` +- Wait until done. Check via `docker compose logs -f ibf-api-service` - As always (see main [README](../README.md)) - Run the seed-script - Run mock-endpoint (or external pipeline) @@ -76,30 +76,30 @@ If there is a problem with your existing database schema, you can always try to These below commands come in handy when you face such issue: - The Docker compose command starts and runs your entire app: - docker-compose up + docker compose up - For dev environment we can use: - docker-compose -f docker-compose.yml -f docker-compose.override.yml up + docker compose -f docker-compose.yml -f docker-compose.override.yml up - Execute this will create a container named ibf-api-service and start a Bash session: - docker-compose exec ibf-api-service bash + docker compose exec ibf-api-service bash - To run seed script: - docker-compose exec ibf-api-service npm run seed + docker compose exec ibf-api-service npm run seed - Detached mode (-d) run command in the background: - docker-compose up -d ibf-api-service: + docker compose up -d ibf-api-service: - Create the Docker image from the Dockerfile in this folder through: docker build -t ibf-api-service - To check the logs of IBF-api-service: - docker-compose logs -f ibf-api-service + docker compose logs -f ibf-api-service - To restart the IBF-api-service in docker: - docker-compose restart ibf-api-service + docker compose restart ibf-api-service - To install the IBF-api-services: - docker-compose exec ibf-api-service npm install + docker compose exec ibf-api-service npm install You can refer this official docker document [here](https://docs.docker.com/engine/reference/commandline/compose_exec/) diff --git a/package.json b/package.json index b2d30d51d5..b5c793b190 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.258.0", "private": true, "scripts": { - "start:services": "docker-compose up -d", + "start:services": "docker compose up -d", "start:interface": "npm start --prefix interfaces/IBF-dashboard/ -- --port 4200", "install:interface": "npm install --no-optional --no-audit --no-fund --prefix interfaces/IBF-dashboard/", "open": "npx npm-run-all open:ibf-api-service open:ibf-dashboard", @@ -33,4 +33,4 @@ "puppeteer": "^8.0.0" }, "pre-commit": "lint" -} \ No newline at end of file +} diff --git a/services/API-service/README.md b/services/API-service/README.md index a5118eeb02..2125ac05b5 100644 --- a/services/API-service/README.md +++ b/services/API-service/README.md @@ -78,7 +78,7 @@ Developers use the following process for this. 1. The attribute 'synchronize' in ormconfig.js is set to 'false' by default. This means that any changes in your entities in code are not automatically reflected in the datamodel. 2. Otherwise TypeORM's migration:generate functionality cannot be used to automatically capture the difference between before (datamodel) and after (entities) state. 3. A developer develops + tests until running into a datamodel change. If that happens - - Generate a migration through `docker-compose exec ibf-api-service npm run migration:generate ` + - Generate a migration through `docker compose exec ibf-api-service npm run migration:generate ` - Immediately run the migration (by restarting ibf-api-service, as migration:run is run upon 'prestart') - Test the feature - Continue developing and repeat this process as many times as needed @@ -125,7 +125,7 @@ Use [ngrok](https://ngrok.com/) to mock an external API service: - In the `WhatsApp sandbox settings` (go to right subaccount > Develop > Messaging > Settings > Whatsapp sandbox settings) as: - `/api/notifications/whatsapp/incoming` in the `WHEN A MESSAGE COMES IN` field - `/api/notifications/whatsapp/status` in the `STATUS CALLBACK URL` field -7. Rebuild the service with `docker-compose -d up ibf-api-service` +7. Rebuild the service with `docker compose -d up ibf-api-service` 8. Add your WhatsApp phone number to the WhatsApp sandbox by texting the code provided in the subaccount to the sandbox phone number 9. Create a new IBF-user through API with your WhatsApp phone number and assigned to the country you are testing for 10. Send a notification (for a country/disasterType with an active trigger) via the `/api/notification/send` endpoint. diff --git a/tools/deploy.sh b/tools/deploy.sh index c4f6351930..8a7ad73f9b 100644 --- a/tools/deploy.sh +++ b/tools/deploy.sh @@ -52,10 +52,10 @@ function deploy() { log "Update containers..." cd "$repo" || return - docker-compose down -v - docker-compose --env-file /dev/null config > inspect.docker-compose.config - docker-compose --env-file /dev/null -f docker-compose.yml up -d --build - docker-compose --env-file /dev/null restart + docker compose down -v + docker compose --env-file /dev/null config > inspect.docker-compose.config + docker compose --env-file /dev/null -f docker-compose.yml up -d --build + docker compose --env-file /dev/null restart # wait 2 minutes for services to go live sleep 2m }