From 5fb3e9e75a1801f5ac22fdbd0fde7699895d43fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 10 Jun 2024 23:47:22 +0530 Subject: [PATCH] refactor(docker): rm duplicate docker-compose.yml Motivation ---------- I strongly suggest to have one `docker-compose.yml` and one `docker-compose.override.yml` in a central directory, e.g. the root directory. I don't see any good reason to scatter the files across sub-directories. If you want to group services, use [profiles](https://docs.docker.com/compose/profiles/). As a follow up, the different `README`s in each sub-directory needs to be updated. If this PR gets merged, I'm willing to do this. How to test ----------- 1. Nothing to test. --- .github/workflows/admin.yml | 9 +--- .github/workflows/backend.yml | 10 +---- .github/workflows/frontend..yml | 10 +---- .github/workflows/presenter.yml | 10 +---- admin/README.md | 14 ------ admin/docker-compose.override.yml | 63 -------------------------- admin/docker-compose.yml | 28 ------------ backend/README.md | 12 ----- backend/docker-compose.override.yml | 40 ----------------- backend/docker-compose.yml | 28 ------------ frontend/README.md | 12 ----- frontend/docker-compose.override.yml | 63 -------------------------- frontend/docker-compose.test.yml | 27 ----------- frontend/docker-compose.yml | 28 ------------ presenter/README.md | 12 ----- presenter/docker-compose.override.yml | 63 -------------------------- presenter/docker-compose.test.yml | 28 ------------ presenter/docker-compose.yml | 28 ------------ tests/README.md | 64 +-------------------------- 19 files changed, 9 insertions(+), 540 deletions(-) delete mode 100644 admin/docker-compose.override.yml delete mode 100644 admin/docker-compose.yml delete mode 100644 backend/docker-compose.override.yml delete mode 100644 backend/docker-compose.yml delete mode 100644 frontend/docker-compose.override.yml delete mode 100644 frontend/docker-compose.test.yml delete mode 100644 frontend/docker-compose.yml delete mode 100644 presenter/docker-compose.override.yml delete mode 100644 presenter/docker-compose.test.yml delete mode 100644 presenter/docker-compose.yml diff --git a/.github/workflows/admin.yml b/.github/workflows/admin.yml index 982e945df3..8ecb2bc22b 100644 --- a/.github/workflows/admin.yml +++ b/.github/workflows/admin.yml @@ -44,29 +44,24 @@ jobs: name: Build Docker Production - Admin needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./admin steps: - name: Checkout code uses: actions/checkout@v4 - name: Admin | Build Docker Production - run: docker compose -f docker-compose.yml build + run: docker compose -f docker-compose.yml build admin docker-development: if: needs.files-changed.outputs.admin == 'true' name: Build Docker Development - Admin needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./admin steps: - name: Checkout code uses: actions/checkout@v4 - name: Admin | Build Docker Development - run: docker compose build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose build admin admin-documentation admin-storybook docs: if: needs.files-changed.outputs.admin-docs == 'true' diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 9c2d25b784..d385c32161 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -49,30 +49,24 @@ jobs: name: Build Docker Production - Backend needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./backend steps: - name: Checkout code uses: actions/checkout@v4 - name: Backend | Build Docker Production - run: docker compose -f docker-compose.yml build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose -f docker-compose.yml build backend docker-development: if: needs.files-changed.outputs.backend == 'true' name: Build Docker Development - Backend needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./backend steps: - name: Checkout code uses: actions/checkout@v4 - name: Backend | Build Docker Development - run: docker compose build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose build backend backend-documentation docs: if: needs.files-changed.outputs.backend-docs == 'true' diff --git a/.github/workflows/frontend..yml b/.github/workflows/frontend..yml index d65c278613..a128ce6a19 100644 --- a/.github/workflows/frontend..yml +++ b/.github/workflows/frontend..yml @@ -44,30 +44,24 @@ jobs: name: Build Docker Production - Frontend needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./frontend steps: - name: Checkout code uses: actions/checkout@v4 - name: Frontend | Build Docker Production - run: docker compose -f docker-compose.yml build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose -f docker-compose.yml build frontend docker-development: if: needs.files-changed.outputs.frontend == 'true' name: Build Docker Development - Frontend needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./frontend steps: - name: Checkout code uses: actions/checkout@v4 - name: Frontend | Build Docker Development - run: docker compose build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose build frontend frontend-documentation frontend-storybook docs: if: needs.files-changed.outputs.frontend-docs == 'true' diff --git a/.github/workflows/presenter.yml b/.github/workflows/presenter.yml index 8a8e13a00a..c38299eeed 100644 --- a/.github/workflows/presenter.yml +++ b/.github/workflows/presenter.yml @@ -44,30 +44,24 @@ jobs: name: Build Docker Production - Presenter needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./presenter steps: - name: Checkout code uses: actions/checkout@v4 - name: Presenter | Build Docker Production - run: docker compose -f docker-compose.yml build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose -f docker-compose.yml build presenter docker-development: if: needs.files-changed.outputs.presenter == 'true' name: Build Docker Development - Presenter needs: files-changed runs-on: ubuntu-latest - env: - WORKING_DIRECTORY: ./presenter steps: - name: Checkout code uses: actions/checkout@v4 - name: Presenter | Build Docker Development - run: docker compose build - working-directory: ${{env.WORKING_DIRECTORY}} + run: docker compose build presenter presenter-documentation presenter-storybook docs: if: needs.files-changed.outputs.presenter-docs == 'true' diff --git a/admin/README.md b/admin/README.md index eb80e68047..40a86645db 100644 --- a/admin/README.md +++ b/admin/README.md @@ -67,20 +67,6 @@ This projects utilizes `storybook` and `chromatic` to develop, document & test f | **Maintenance** | | | `npm run update` | Check for updates | -### Docker - -### Docker development mode - -```bash -docker compose up -``` - -### Docker can be run in production mode - -```bash -docker compose -f docker-compose.yml up -``` - ### Chromatic In order to use the chromatic workflow you need to provide a `CHROMATIC_PROJECT_TOKEN` in the repository secrets. diff --git a/admin/docker-compose.override.yml b/admin/docker-compose.override.yml deleted file mode 100644 index bd020bfac6..0000000000 --- a/admin/docker-compose.override.yml +++ /dev/null @@ -1,63 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-development - build: - target: development - ports: - # development server port - - 24678:24678 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - frontend_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - - ####################################################### - # STORYBOOK ########################################### - ####################################################### - storybook: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-storybook - build: - target: storybook - ports: - - 6006:6006 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - storybook_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - - ####################################################### - # DOCUMENTATION ####################################### - ####################################################### - documentation: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-documentation - build: - target: documentation - ports: - - 8080:8080 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - documentation_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - -volumes: - frontend_node_modules: - storybook_node_modules: - documentation_node_modules: diff --git a/admin/docker-compose.yml b/admin/docker-compose.yml deleted file mode 100644 index 536b3b1512..0000000000 --- a/admin/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-production - build: - context: . - target: production - networks: - - external-net - - internal-net - ports: - - 3000:3000 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/app" - # - PORT=3000 - # - BUILD_DATE="1970-01-01T00:00:00.00Z" - # - BUILD_VERSION="0.0.0.0" - # - BUILD_COMMIT="0000000" - - NODE_ENV=production - -networks: - external-net: - internal-net: - internal: true diff --git a/backend/README.md b/backend/README.md index 4acc07f843..0225da3c09 100644 --- a/backend/README.md +++ b/backend/README.md @@ -48,18 +48,6 @@ The following commands are available: | **Maintenance** | | | `npm run update` | Check for updates | -### Docker - -Docker can be run in development mode utilizing `docker-compose.overwrite.yml`: -```bash -docker compose up -``` - -Docker can be run in production mode: -```bash -docker compose -f docker-compose.yml up -``` - ### Update You can get a list of packes to update by running `npm run update`. diff --git a/backend/docker-compose.override.yml b/backend/docker-compose.override.yml deleted file mode 100644 index 8a9d2a63da..0000000000 --- a/backend/docker-compose.override.yml +++ /dev/null @@ -1,40 +0,0 @@ -services: - ####################################################### - # BACKEND ############################################# - ####################################################### - backend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/backend:local-development - build: - target: development - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - backend_node_modules:/server/node_modules - # bind the local folder to the docker to allow live reload - - ./:/server - - ####################################################### - # DOCUMENTATION ####################################### - ####################################################### - documentation: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/backend:local-documentation - build: - target: documentation - ports: - - 8080:8080 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - documentation_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - -volumes: - backend_node_modules: - documentation_node_modules: diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml deleted file mode 100644 index 156057195b..0000000000 --- a/backend/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - ####################################################### - # BACKEND ############################################# - ####################################################### - backend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/backend:local-production - build: - context: . - target: production - networks: - - external-net - - internal-net - ports: - - 4000:4000 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/server" - # - PORT=4000 - # - BUILD_DATE="1970-01-01T00:00:00.00Z" - # - BUILD_VERSION="0.0.0.0" - # - BUILD_COMMIT="0000000" - - NODE_ENV=production - -networks: - external-net: - internal-net: - internal: true diff --git a/frontend/README.md b/frontend/README.md index 4644f32121..1ab31c1741 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -66,18 +66,6 @@ The following commands are available: | **Maintenance** | | | `npm run update` | Check for updates | -### Docker - -Docker can be run in development mode utilizing `docker-compose.overwrite.yml`: -```bash -docker compose up -``` - -Docker can be run in production mode: -```bash -docker compose -f docker-compose.yml up -``` - ### Chromatic In order to use the chromatic workflow you need to provide a `CHROMATIC_PROJECT_TOKEN` in the repository secrets. diff --git a/frontend/docker-compose.override.yml b/frontend/docker-compose.override.yml deleted file mode 100644 index bd020bfac6..0000000000 --- a/frontend/docker-compose.override.yml +++ /dev/null @@ -1,63 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-development - build: - target: development - ports: - # development server port - - 24678:24678 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - frontend_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - - ####################################################### - # STORYBOOK ########################################### - ####################################################### - storybook: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-storybook - build: - target: storybook - ports: - - 6006:6006 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - storybook_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - - ####################################################### - # DOCUMENTATION ####################################### - ####################################################### - documentation: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-documentation - build: - target: documentation - ports: - - 8080:8080 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - documentation_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - -volumes: - frontend_node_modules: - storybook_node_modules: - documentation_node_modules: diff --git a/frontend/docker-compose.test.yml b/frontend/docker-compose.test.yml deleted file mode 100644 index 2bf736c787..0000000000 --- a/frontend/docker-compose.test.yml +++ /dev/null @@ -1,27 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - image: dreammall/frontend:local-test - build: - context: . - target: test - networks: - - external-net - - internal-net - ports: - - 3000:3000 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/app" - # - PORT=3000 - # - BUILD_DATE="1970-01-01T00:00:00.00Z" - # - BUILD_VERSION="0.0.0.0" - # - BUILD_COMMIT="0000000" - - NODE_ENV=production - -networks: - external-net: - internal-net: - internal: true diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml deleted file mode 100644 index 536b3b1512..0000000000 --- a/frontend/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-production - build: - context: . - target: production - networks: - - external-net - - internal-net - ports: - - 3000:3000 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/app" - # - PORT=3000 - # - BUILD_DATE="1970-01-01T00:00:00.00Z" - # - BUILD_VERSION="0.0.0.0" - # - BUILD_COMMIT="0000000" - - NODE_ENV=production - -networks: - external-net: - internal-net: - internal: true diff --git a/presenter/README.md b/presenter/README.md index 0b6e759bc2..2ca5a88912 100644 --- a/presenter/README.md +++ b/presenter/README.md @@ -67,18 +67,6 @@ This projects utilizes `storybook` and `chromatic` to develop, document & test f | **Maintenance** | | | `npm run update` | Check for updates | -### Docker - -Docker can be run in development mode utilizing `docker-compose.overwrite.yml`: -```bash -docker compose up -``` - -Docker can be run in production mode: -```bash -docker compose -f docker-compose.yml up -``` - ### Chromatic In order to use the chromatic workflow you need to provide a `CHROMATIC_PROJECT_TOKEN` in the repository secrets. diff --git a/presenter/docker-compose.override.yml b/presenter/docker-compose.override.yml deleted file mode 100644 index bd020bfac6..0000000000 --- a/presenter/docker-compose.override.yml +++ /dev/null @@ -1,63 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-development - build: - target: development - ports: - # development server port - - 24678:24678 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - frontend_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - - ####################################################### - # STORYBOOK ########################################### - ####################################################### - storybook: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-storybook - build: - target: storybook - ports: - - 6006:6006 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - storybook_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - - ####################################################### - # DOCUMENTATION ####################################### - ####################################################### - documentation: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-documentation - build: - target: documentation - ports: - - 8080:8080 - environment: - - NODE_ENV=development - volumes: - # This makes sure the docker container has its own node modules. - # Therefore it is possible to have a different node version on the host machine - - documentation_node_modules:/app/node_modules - # bind the local folder to the docker to allow live reload - - ./:/app - -volumes: - frontend_node_modules: - storybook_node_modules: - documentation_node_modules: diff --git a/presenter/docker-compose.test.yml b/presenter/docker-compose.test.yml deleted file mode 100644 index 415948b616..0000000000 --- a/presenter/docker-compose.test.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - presenter: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/presenter:local-test - build: - context: . - target: test - networks: - - external-net - - internal-net - ports: - - 3001:3001 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/app" - - PORT=3001 - # - BUILD_DATE="1970-01-01T00:00:00.00Z" - # - BUILD_VERSION="0.0.0.0" - # - BUILD_COMMIT="0000000" - - NODE_ENV=test - -networks: - external-net: - internal-net: - internal: true diff --git a/presenter/docker-compose.yml b/presenter/docker-compose.yml deleted file mode 100644 index 536b3b1512..0000000000 --- a/presenter/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - ####################################################### - # FRONTEND ############################################ - ####################################################### - frontend: - # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: it4c/frontend:local-production - build: - context: . - target: production - networks: - - external-net - - internal-net - ports: - - 3000:3000 - environment: - # Envs used in Dockerfile - # - DOCKER_WORKDIR="/app" - # - PORT=3000 - # - BUILD_DATE="1970-01-01T00:00:00.00Z" - # - BUILD_VERSION="0.0.0.0" - # - BUILD_COMMIT="0000000" - - NODE_ENV=production - -networks: - external-net: - internal-net: - internal: true diff --git a/tests/README.md b/tests/README.md index e06ae2b0b9..5cf889dd2b 100644 --- a/tests/README.md +++ b/tests/README.md @@ -31,69 +31,7 @@ These features of the DreamMall software are covered by the end-to-end tests: Running and testing the application requires `nodejs` (`>= v21`), `npm` and `docker`. ### Boot up the test system -For local testing there are two ways to boot up the test system. - -#### a) As in the Github CI -Except the host OS, this approach is exactly the same as we run in the [end-to-end test workflow](.github/workflows/e2e.run.tests.yml). - -```bash -# Boot up Authentik via Docker ########################## -# change to Authentik directory -cd authentik/ -# unpack database -./database.unpack.sh -# boot up Authentik via Docker -docker compose up -d - -# Boot up Frontend via Docker ########################### -# change to frontend directory -cd ../frontend/ -# copy .env file -cp .env.dist .env -# boot up frontend via Docker -docker compose -f docker-compose.test.yml up -d frontend - -# Boot up Presenter via Docker ########################## -# change to presenter directory -cd ../presenter/ -# copy .env file -cp .env.dist .env -# boot up presenter via Docker -docker compose -f docker-compose.test.yml up -d presenter -``` - -#### b) Less resource-intense -This approach requires less resources and time to boot up the test system and is suitable for local debugging. -But keep in mind that here the underlying technical infrastructure differes from the infrastructure in the Github CI. - -```bash -# Boot up Authentik via Docker ########################## -# change to Authentik directory -cd authentik/ -# unpack database -./database.unpack.sh -# boot up Authentik via Docker -docker compose up -d - -# Boot up Frontend via npm ############################## -# in separate console change to frontend directory -cd frontend/ -# copy .env file -cp .env.dist .env -# install packages -npm install -# run frontend in production mode -npm run prod - -# Boot up Presenter via npm ############################# -# in separate console change to presenter directory -cd presenter/ -# copy .env file -# install packages -npm install -# run frontend in production mode -npm run prod -``` +Follow the setup in the [end-to-end test workflow](.github/workflows/e2e.run.tests.yml). ### Run the tests At first the required packages have to be install