From 6048ac6152c0001c06ab12087fbb60574a4fc32c Mon Sep 17 00:00:00 2001 From: Spencer Bliven Date: Thu, 27 Jun 2024 14:39:31 +0200 Subject: [PATCH] Revert docker-compose.yaml changes based on feedback Also a small update to readme (use of `docker-compose` is deprecated - revert 'depends_on' change. This was a [docker bug in 2.24](https://github.com/docker/compose/issues/11544) - Remove unneeded comments --- dev/README.md | 20 ++++++++++---------- dev/docker-compose.yaml | 10 ++-------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/dev/README.md b/dev/README.md index e5baeb5..d29378a 100644 --- a/dev/README.md +++ b/dev/README.md @@ -2,7 +2,7 @@ ## Overview -Development can be done running local docker containers. First `docker-compose` is used +Development can be done running local docker containers. First `docker compose` is used to launch containers for each service. Most containers do not start the service directly, allowing this to be done manually from inside the container (eg using VS Code Dev Containers). Commands for each service are given below. @@ -17,13 +17,13 @@ git submodule update --init --recursive --remote ## Starting containers ### :warning: IMPORTANT -The docker-compose builds the containers from the Dockerfile of each submodule, thus +The `docker compose` builds the containers from the Dockerfile of each submodule, thus using the submodule checked out to a particular commit. It is often the case that when setting up the environment one wants the components to be checked out automatically to the latest on main. The command above (`git submodule update --init --recursive --remote`) does that but might break any component where a non-backwards compatible change was applied. We reference in the config of each components the latest commit -(.git-commit-sha) of the submodule where the docker-compose was run and worked the last +(.git-commit-sha) of the submodule where `docker compose` was run and worked the last time, whenever the submodule commit is different from the one referenced in the scicat-ci repo. @@ -35,11 +35,11 @@ Build the docker containers with the suitable ```bash export COMPOSE_PROFILES= -docker-compose -f docker-compose.yaml up -d --force-recreate --build --no-deps +docker compose -f docker-compose.yaml up -d --force-recreate --build --no-deps ``` All the application containers (excluding the db -mongo- and the db_seeding --mongo_seed-) are meant to be used for development so docker-compose starts, rather than +-mongo_seed-) are meant to be used for development so `docker compose` starts, rather than the applications, environments where the development environment of each application is set up. This means that, to run the application, one has to attach to the container and start it. @@ -55,9 +55,9 @@ backend and the frontend. ```bash export COMPOSE_PROFILES=be,fe ``` -2. run docker-compose: +2. run docker compose: ```bash -docker-compose -f docker-compose.yaml up --force-recreate --build --no-deps -d +docker compose -f docker-compose.yaml up --force-recreate --build --no-deps -d ``` This will start four containers: the be container, the fe one, the mongodb database and @@ -70,9 +70,9 @@ mongo. ```bash export COMPOSE_PROFILES=be_next,fe ``` -2. run docker-compose: +2. run docker compose: ```bash -docker-compose -f docker-compose.yaml up --force-recreate --build --no-deps -d +docker compose -f docker-compose.yaml up --force-recreate --build --no-deps -d ``` As before, this will start four containers: the be_next container, the fe one, the mongo @@ -191,7 +191,7 @@ This compose file creates a new docker volume with test data. Removing this requ adding `--volumes` when shutting down the containers: ```bash -docker-compose -f docker-compose.yaml down --volumes +docker compose -f docker-compose.yaml down --volumes ``` If this is omitted it may eventually lead to your docker virtual disk filling up. If diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 2e8f1a6..b65eb1c 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -9,8 +9,6 @@ services: - be - be_next - oi - ports: - - 27017:27017 mongodb_seed: image: mongo @@ -22,6 +20,8 @@ services: - "-c" - "chmod u+x /mnt/mongo_import.sh && /mnt/mongo_import.sh" user: "0:0" + depends_on: + - mongodb restart: on-failure profiles: - never @@ -32,8 +32,6 @@ services: - DATABASE=be profiles: - be - depends_on: - - mongodb mongodb_seed_be_next: extends: mongodb_seed @@ -41,8 +39,6 @@ services: - DATABASE=be_next profiles: - be_next - depends_on: - - mongodb be: build: ../backend/. @@ -75,8 +71,6 @@ services: - /frontend/dist command: /bin/sh -c "while true; do sleep 600; done" ports: - # Dev image with `node start` uses port 4200 - # For the upstream dockerfile with nginx, use 4200:80 - 4200:4200 profiles: - fe