From 12f325bc343a5656e42cd383663a0b4748ae8285 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 14 Dec 2023 10:33:23 +0100 Subject: [PATCH 01/24] first version of integrated docker-compose files --- Dockerfile | 53 +++++++++++++++++++++++++++++++++++++ docker-compose.override.yml | 29 ++++++++++++++++++++ docker-compose.yml | 12 +++++++++ 3 files changed, 94 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..f000563221 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +FROM node:21-alpine3.17 as base + +# ENVs (available in production aswell, can be overwritten by commandline or env file) +## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame +ENV DOCKER_WORKDIR="/app" +## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0 +ENV BUILD_DATE="1970-01-01T00:00:00.00Z" +## We cannot do $(npm run version).${BUILD_NUMBER} here so we default to 0.0.0.0 +ENV BUILD_VERSION="0.0.0.0" +## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000 +ENV BUILD_COMMIT="0000000" +## SET NODE_ENV +ENV NODE_ENV="production" +## App relevant Envs +ENV PORT="3000" + +# Labels +LABEL org.label-schema.build-date="${BUILD_DATE}" +LABEL org.label-schema.name="it4c:frontend" +LABEL org.label-schema.description="IT4C Frontend Boilerplate" +LABEL org.label-schema.usage="https://github.com/IT4Change/boilerplate-frontend/blob/master/README.md" +LABEL org.label-schema.url="https://github.com/IT4Change/boilerplate-frontend" +LABEL org.label-schema.vcs-url="https://github.com/IT4Change/boilerplate-frontend/tree/master/" +LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}" +LABEL org.label-schema.vendor="IT4C" +LABEL org.label-schema.version="${BUILD_VERSION}" +LABEL org.label-schema.schema-version="1.0" +LABEL maintainer="info@it4c.dev" + +# Install Additional Software +## install: node-gyp dependencies +# RUN apk --no-cache add g++ make python3 + +# Settings +## Expose Container Port +EXPOSE ${PORT} + +## Workdir +RUN mkdir -p ${DOCKER_WORKDIR} +WORKDIR ${DOCKER_WORKDIR} + +################################################################################## +# DOCUMENTATION ################################################################## +################################################################################## +FROM base as documentation + +# We don't need to copy or build anything since we gonna bind to the +# local filesystem which will need a rebuild anyway + +# Run command +# (for development we need to execute npm install since the +# node_modules are on another volume and need updating) +CMD /bin/sh -c "npm install && npm run docs:dev" diff --git a/docker-compose.override.yml b/docker-compose.override.yml index e13884a97b..7d42620b4e 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -9,3 +9,32 @@ services: networks: - internal-net - external-net + + # ###################################################### + # 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: dreammall/dreammall:local-documentation + build: + target: documentation + environment: + - NODE_ENV="development" + # - DEBUG=true + ports: + - 8080:8080 + 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 + + storybook: + extends: + file: presenter/docker-compose.override.yml + service: storybook + +volumes: + storybook_node_modules: + documentation_node_modules: \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index bed27a62de..9ad5126c8a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,16 @@ services: volumes: - db_vol:/var/lib/mysql + presenter: + extends: + file: presenter/docker-compose.override.yml + service: frontend + + backend: + extends: + file: backend/docker-compose.override.yml + service: backend + networks: external-net: internal-net: @@ -27,3 +37,5 @@ networks: volumes: db_vol: + frontend_node_modules: + backend_node_modules: From ebe19a8373f318c32b29d82ee0f9f514e6cfec59 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 14 Dec 2023 10:59:48 +0100 Subject: [PATCH 02/24] adjust docker file --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f000563221..e55f99e977 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,13 +16,13 @@ ENV PORT="3000" # Labels LABEL org.label-schema.build-date="${BUILD_DATE}" -LABEL org.label-schema.name="it4c:frontend" -LABEL org.label-schema.description="IT4C Frontend Boilerplate" -LABEL org.label-schema.usage="https://github.com/IT4Change/boilerplate-frontend/blob/master/README.md" -LABEL org.label-schema.url="https://github.com/IT4Change/boilerplate-frontend" -LABEL org.label-schema.vcs-url="https://github.com/IT4Change/boilerplate-frontend/tree/master/" +LABEL org.label-schema.name="dreammall" +LABEL org.label-schema.description="DreamMall" +LABEL org.label-schema.usage="https://github.com/dreammall-earth/dreammall.earth/blob/master/README.md" +LABEL org.label-schema.url="https://github.com/dreammall-earth/dreammall.earth/" +LABEL org.label-schema.vcs-url="https://github.com/dreammall-earth/dreammall.earth/tree/master/" LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}" -LABEL org.label-schema.vendor="IT4C" +LABEL org.label-schema.vendor="DreamMall" LABEL org.label-schema.version="${BUILD_VERSION}" LABEL org.label-schema.schema-version="1.0" LABEL maintainer="info@it4c.dev" From 4f037265cd49acedb194219e603120547fd222f9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 01:53:28 +0100 Subject: [PATCH 03/24] clean presenter docker setup --- presenter/Dockerfile | 2 +- presenter/docker-compose.override.yml | 35 ++++++++++++++------------- presenter/docker-compose.yml | 13 ++++------ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/presenter/Dockerfile b/presenter/Dockerfile index 6cbf431d02..dae836bb6d 100644 --- a/presenter/Dockerfile +++ b/presenter/Dockerfile @@ -86,7 +86,7 @@ FROM base as build # Copy everything COPY . . # npm install -RUN npm install --frozen-lockfile --non-interactive +RUN npm install --include=dev --frozen-lockfile --non-interactive # npm build RUN npm run build diff --git a/presenter/docker-compose.override.yml b/presenter/docker-compose.override.yml index 4f3c1ecc97..4b2dde8c6f 100644 --- a/presenter/docker-compose.override.yml +++ b/presenter/docker-compose.override.yml @@ -1,16 +1,19 @@ version: '3.4' + services: - # ###################################################### - # FRONTEND ############################################# - # ###################################################### + ####################################################### + # 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" - # - DEBUG=true + - 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 @@ -18,19 +21,18 @@ services: # bind the local folder to the docker to allow live reload - ./:/app - # ###################################################### - # STORYBOOK ############################################ - # ###################################################### + ####################################################### + # 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 - environment: - - NODE_ENV="development" - # - DEBUG=true 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 @@ -38,19 +40,18 @@ services: # bind the local folder to the docker to allow live reload - ./:/app - # ###################################################### - # DOCUMENTATION ######################################## - # ###################################################### + ####################################################### + # 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 - environment: - - NODE_ENV="development" - # - DEBUG=true 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 diff --git a/presenter/docker-compose.yml b/presenter/docker-compose.yml index dbc715bd21..a084ff0a59 100644 --- a/presenter/docker-compose.yml +++ b/presenter/docker-compose.yml @@ -1,9 +1,9 @@ -# This file defines the production settings. It is overwritten by docker-compose.override.yml, -# which defines the development settings. The override.yml is loaded by default. Therefore it -# is required to explicitly define if you want an production build: -# > docker-compose -f docker-compose.yml up version: '3.4' + 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 @@ -22,10 +22,7 @@ services: # - BUILD_DATE="1970-01-01T00:00:00.00Z" # - BUILD_VERSION="0.0.0.0" # - BUILD_COMMIT="0000000" - - NODE_ENV="production" - # env_file: - # - ./.env - # - ./frontend/.env + - NODE_ENV=production networks: external-net: From ded65cef3b5883ea16275f2a2abbe85d70425a8f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 01:54:06 +0100 Subject: [PATCH 04/24] clean backend docker setup --- backend/docker-compose.override.yml | 10 +++++----- backend/docker-compose.yml | 13 +++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/backend/docker-compose.override.yml b/backend/docker-compose.override.yml index 75ca26eba2..7dc5f26979 100644 --- a/backend/docker-compose.override.yml +++ b/backend/docker-compose.override.yml @@ -1,16 +1,16 @@ version: '3.4' + services: - # ###################################################### - # BACKEND ############################################## - # ###################################################### + ####################################################### + # 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" - # - DEBUG=true + - 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 diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index 2a40a57828..08583c9075 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -1,9 +1,9 @@ -# This file defines the production settings. It is overwritten by docker-compose.override.yml, -# which defines the development settings. The override.yml is loaded by default. Therefore it -# is required to explicitly define if you want an production build: -# > docker-compose -f docker-compose.yml up version: '3.4' + 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 @@ -22,10 +22,7 @@ services: # - BUILD_DATE="1970-01-01T00:00:00.00Z" # - BUILD_VERSION="0.0.0.0" # - BUILD_COMMIT="0000000" - - NODE_ENV="production" - # env_file: - # - ./.env - # - ./backend/.env + - NODE_ENV=production networks: external-net: From 236894b8f9f2370ce44b7ff3329befc0f86c1967 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 01:54:18 +0100 Subject: [PATCH 05/24] remove docker-compose.test.yml --- .github/workflows/backend.test.unit.code.yml | 2 +- docker-compose.test.yml | 22 -------------------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 docker-compose.test.yml diff --git a/.github/workflows/backend.test.unit.code.yml b/.github/workflows/backend.test.unit.code.yml index e2436e73b9..c04c5f14b5 100644 --- a/.github/workflows/backend.test.unit.code.yml +++ b/.github/workflows/backend.test.unit.code.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v4 - name: Backend | docker-compose database - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database + run: docker-compose -f docker-compose.yml up --detach --no-deps database - name: Backend | Unit run: npm install && npm run db:migrate && npm run test:unit diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100644 index 53cdc359a4..0000000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: "3.4" - -services: - ######################################################### - ## MARIADB ############################################## - ######################################################### - database: - image: dreammall.earth/database:test - networks: - - internal-net - - external-net - volumes: - - db_test_vol:/var/lib/mysql - -networks: - external-net: - internal-net: - internal: true - -volumes: - db_test_vol: - From a50e3fe8d78f8dbe265b64980c45ed601d43b61e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:08:21 +0100 Subject: [PATCH 06/24] docker compose files --- docker-compose.override.yml | 103 ++++++++++++++++++++++++++++++------ docker-compose.yml | 55 +++++++++++++++---- 2 files changed, 133 insertions(+), 25 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 7d42620b4e..a9a5c9a851 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,28 +1,103 @@ version: "3.4" services: - - ######################################################### - ## MARIADB ############################################## - ######################################################### + ######################################################## + # DATABASE ############################################# + ######################################################## database: networks: - internal-net - external-net - # ###################################################### + ######################################################## + # PRESENTER ############################################ + ######################################################## + 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: dreammall/presenter: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 + - presenter_node_modules:/app/node_modules + # bind the local folder to the docker to allow live reload + - ./presenter:/app + + ####################################################### + # PRESENTER STORYBOOK ################################# + ####################################################### + presenter-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: dreammall/presenter:local-storybook + build: + context: ./presenter + 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 + - presenter_storybook_node_modules:/app/node_modules + # bind the local folder to the docker to allow live reload + - ./presenter:/app + + ####################################################### + # PRESENTER DOCUMENTATION ############################# + ####################################################### + presenter-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: + context: ./presenter + target: documentation + ports: + - 8081: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 + - presenter_documentation_node_modules:/app/node_modules + # bind the local folder to the docker to allow live reload + - ./:/app + + ####################################################### + # 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 + - ./backend:/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: dreammall/dreammall:local-documentation build: target: documentation - environment: - - NODE_ENV="development" - # - DEBUG=true 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 @@ -30,11 +105,9 @@ services: # bind the local folder to the docker to allow live reload - ./:/app - storybook: - extends: - file: presenter/docker-compose.override.yml - service: storybook - volumes: - storybook_node_modules: + presenter_node_modules: + presenter_storybook_node_modules: + presenter_documentation_node_modules: + backend_node_modules: documentation_node_modules: \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 9ad5126c8a..46e4c62ee5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,9 @@ version: "3.4" services: - - ######################################################### - ## MARIADB ############################################## - ######################################################### + ######################################################## + # DATABASE ############################################# + ######################################################## database: build: context: ./database @@ -20,15 +19,51 @@ services: volumes: - db_vol:/var/lib/mysql + ######################################################## + # PRESENTER ############################################ + ######################################################## presenter: - extends: - file: presenter/docker-compose.override.yml - service: 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: dreammall/presenter:local-production + build: + context: ./presenter + 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 + ####################################################### + # BACKEND ############################################# + ####################################################### backend: - extends: - file: backend/docker-compose.override.yml - service: 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: ./backend + 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: From 33466a718c2a5c89e79093dc3ffbc3d334bdcecd Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:21:46 +0100 Subject: [PATCH 07/24] depends on database, corrected documentation path --- docker-compose.override.yml | 2 +- docker-compose.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index a9a5c9a851..1da106f2b4 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -67,7 +67,7 @@ services: # Therefore it is possible to have a different node version on the host machine - presenter_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - - ./:/app + - ./presenter:/app ####################################################### # BACKEND ############################################# diff --git a/docker-compose.yml b/docker-compose.yml index 46e4c62ee5..0d183ca7c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,6 +51,8 @@ services: build: context: ./backend target: production + depends_on: + - database networks: - external-net - internal-net From c9b187705e539e729b85565364b8c27e867dd885 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:30:13 +0100 Subject: [PATCH 08/24] document docker endpoints --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 6dfb239a40..6c278c518a 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,20 @@ The following commands are available: | **Release** | | | `npm run release` | Propagate release version & generate changelog | +## Docker + +The following endpoints are provided if `docker compose` is used: + +| Endpoint | Description | +|----------------------------------------------------------------------|----------------------------| +| [http://localhost:3306](http://localhost:3306) | MySQL Database | +| [http://localhost:4000/graphql](http://localhost:4000/graphql) | Backend GraphQL API | +| [http://localhost:4000/playground](http://localhost:4000/playground) | Backend GraphQL Playground | +| [http://localhost:3000](http://localhost:3000) | Presenter Frontend | +| [http://localhost:8081](http://localhost:8081) | Presenter Documentation | +| [http://localhost:6006](http://localhost:6006) | Presenter Storybook | +| [http://localhost:8080](http://localhost:8080) | Documentation | + ## How to release Generate a new version using `npm version --git-tag-version=false patch|minor|major`. From f2ce29472df22c47f5ef74c6b10b8201a8b8535d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:36:16 +0100 Subject: [PATCH 09/24] backend documentation --- backend/docker-compose.override.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/docker-compose.override.yml b/backend/docker-compose.override.yml index 7dc5f26979..e6de57d442 100644 --- a/backend/docker-compose.override.yml +++ b/backend/docker-compose.override.yml @@ -18,6 +18,25 @@ services: # 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: From f33b1a28aea2f1d208833d0080ec32d423b48d49 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:37:29 +0100 Subject: [PATCH 10/24] fix docker file --- backend/Dockerfile | 2 +- docker-compose.override.yml | 34 +++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 34669e28d2..c2b66cdf3b 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -63,7 +63,7 @@ FROM base as documentation # Run command # (for development we need to execute npm install since the # node_modules are on another volume and need updating) -# CMD /bin/sh -c "npm install && npm run docs:dev" +CMD /bin/sh -c "npm install && npm run docs:dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 1da106f2b4..81c5a1b1f3 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -25,7 +25,7 @@ services: 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 - - presenter_node_modules:/app/node_modules + #- presenter_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -45,7 +45,7 @@ services: 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 - - presenter_storybook_node_modules:/app/node_modules + #- presenter_storybook_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -54,7 +54,7 @@ services: ####################################################### presenter-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 + image: dreammall/presenter:local-documentation build: context: ./presenter target: documentation @@ -65,7 +65,7 @@ services: 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 - - presenter_documentation_node_modules:/app/node_modules + #- presenter_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -74,7 +74,7 @@ services: ####################################################### 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 + image: dreammall/backend:local-development build: target: development environment: @@ -82,10 +82,30 @@ services: 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 + #- backend_node_modules:/server/node_modules # bind the local folder to the docker to allow live reload - ./backend:/server + ####################################################### + # BACKEND DOCUMENTATION ############################### + ####################################################### + backend-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: dreammall/backend:local-documentation + build: + context: ./backend + target: documentation + ports: + - 8082: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 + #- backend_documentation_node_modules:/app/node_modules + # bind the local folder to the docker to allow live reload + - ./backend:/app + ######################################################## # DOCUMENTATION ######################################## ######################################################## @@ -101,7 +121,7 @@ services: 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 + #- documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./:/app From 74368b1c77b504f120a99c9d883f4b67b2843ff2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:42:32 +0100 Subject: [PATCH 11/24] missing context --- docker-compose.override.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 81c5a1b1f3..cf1211e043 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -76,6 +76,7 @@ services: # 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: dreammall/backend:local-development build: + context: ./backend target: development environment: - NODE_ENV=development From 6de9dbc4e24888224925b1f8eb2adc33aa0720d2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 02:59:27 +0100 Subject: [PATCH 12/24] fix backend --- backend/prisma/schema.prisma | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index cdaa251b47..90717229e9 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { provider = "prisma-client-js" + binaryTargets = ["native", "linux-musl-openssl-3.0.x"] } datasource db { From f84e0ea4dabe412d52443ee27f974ae130e58905 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 03:08:35 +0100 Subject: [PATCH 13/24] corrected path --- docker-compose.override.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index cf1211e043..df0e31a70e 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -105,7 +105,7 @@ services: # Therefore it is possible to have a different node version on the host machine #- backend_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - - ./backend:/app + - ./backend:/server ######################################################## # DOCUMENTATION ######################################## From 9026eb7a9628085e2ec7977dfb1ad6035382f55c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 03:15:04 +0100 Subject: [PATCH 14/24] copy dreammall logo to .vuepress folder to limit docker context requirement --- backend/.vuepress/assets/dreammall-logo.svg | 42 +++++++++++++++++++++ backend/README.md | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backend/.vuepress/assets/dreammall-logo.svg diff --git a/backend/.vuepress/assets/dreammall-logo.svg b/backend/.vuepress/assets/dreammall-logo.svg new file mode 100644 index 0000000000..0be57a8477 --- /dev/null +++ b/backend/.vuepress/assets/dreammall-logo.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/README.md b/backend/README.md index 6aa913bbd2..41304f13e2 100644 --- a/backend/README.md +++ b/backend/README.md @@ -13,7 +13,7 @@ The Dreammall backend. -![](../presenter/src/assets/dreammall-logo.svg) +![](.vuepress/assets/dreammall-logo.svg) ## Requirements & Technology From e8926c342414ddbea597328d5ce48eca58e063c1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 10:56:42 +0100 Subject: [PATCH 15/24] define database connection url to allow to connect from internal --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 0d183ca7c2..618341f879 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,6 +59,7 @@ services: ports: - 4000:4000 environment: + - DATABASE_URL=mysql://root:@database:3306/dreammall.earth # Envs used in Dockerfile # - DOCKER_WORKDIR="/server" # - PORT=4000 From 1ef3cb90e201c7a72d40dd7f5cf4de1d96f2245e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 11:01:13 +0100 Subject: [PATCH 16/24] use docker-compose.override since there the database has access to external net --- .github/workflows/backend.test.unit.code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend.test.unit.code.yml b/.github/workflows/backend.test.unit.code.yml index c04c5f14b5..5f9204d289 100644 --- a/.github/workflows/backend.test.unit.code.yml +++ b/.github/workflows/backend.test.unit.code.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v4 - name: Backend | docker-compose database - run: docker-compose -f docker-compose.yml up --detach --no-deps database + run: docker-compose up --detach --no-deps database - name: Backend | Unit run: npm install && npm run db:migrate && npm run test:unit From 89f6cb362eb68b5ea258df7b013d6a5097fd316e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 11:06:08 +0100 Subject: [PATCH 17/24] quote DATABASE_URL --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 618341f879..656c402a97 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: ports: - 4000:4000 environment: - - DATABASE_URL=mysql://root:@database:3306/dreammall.earth + - DATABASE_URL="mysql://root:@database:3306/dreammall.earth" # Envs used in Dockerfile # - DOCKER_WORKDIR="/server" # - PORT=4000 From 9b6bef0aca659b1989f567c2d54de2ccc306075a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 11:08:13 +0100 Subject: [PATCH 18/24] fix unit tests --- .github/workflows/backend.test.unit.code.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend.test.unit.code.yml b/.github/workflows/backend.test.unit.code.yml index 5f9204d289..8116d9bf11 100644 --- a/.github/workflows/backend.test.unit.code.yml +++ b/.github/workflows/backend.test.unit.code.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v4 - name: Backend | docker-compose database - run: docker-compose up --detach --no-deps database + run: docker-compose -f docker-compose.yml -f docker-compose.override.yml up --detach --no-deps database - name: Backend | Unit run: npm install && npm run db:migrate && npm run test:unit diff --git a/docker-compose.yml b/docker-compose.yml index 656c402a97..618341f879 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: ports: - 4000:4000 environment: - - DATABASE_URL="mysql://root:@database:3306/dreammall.earth" + - DATABASE_URL=mysql://root:@database:3306/dreammall.earth # Envs used in Dockerfile # - DOCKER_WORKDIR="/server" # - PORT=4000 From 5480339181b9e4665a85d51af1e46015f7634a12 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 11:49:29 +0100 Subject: [PATCH 19/24] fix unit tests --- .github/workflows/backend.test.unit.code.yml | 2 +- docker-compose.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend.test.unit.code.yml b/.github/workflows/backend.test.unit.code.yml index 8116d9bf11..c04c5f14b5 100644 --- a/.github/workflows/backend.test.unit.code.yml +++ b/.github/workflows/backend.test.unit.code.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v4 - name: Backend | docker-compose database - run: docker-compose -f docker-compose.yml -f docker-compose.override.yml up --detach --no-deps database + run: docker-compose -f docker-compose.yml up --detach --no-deps database - name: Backend | Unit run: npm install && npm run db:migrate && npm run test:unit diff --git a/docker-compose.yml b/docker-compose.yml index 618341f879..edac3052eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - MARIADB_USER=root networks: - internal-net + - external-net ports: - 3306:3306 volumes: From fb3250d0e036a1594d113b95a78bff1972939158 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Feb 2024 11:56:53 +0100 Subject: [PATCH 20/24] docker build for backend --- .../workflows/backend.test.build.docker.yml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/backend.test.build.docker.yml diff --git a/.github/workflows/backend.test.build.docker.yml b/.github/workflows/backend.test.build.docker.yml new file mode 100644 index 0000000000..3fb35beda7 --- /dev/null +++ b/.github/workflows/backend.test.build.docker.yml @@ -0,0 +1,46 @@ +name: "backend:test:build test docker" + +on: push + +jobs: + # only (but most important) job from this workflow required for pull requests + # check results serve as run conditions for all other jobs here + files-changed: + name: Detect File Changes - backend-test-build-docker + runs-on: ubuntu-latest + outputs: + changes: ${{ steps.changes.outputs.backend-test-build-docker }} + steps: + - uses: actions/checkout@v4 + + - name: Check for frontend file changes + uses: dorny/paths-filter@v3.0.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + build-production: + if: needs.files-changed.outputs.changes == 'true' + name: Build Docker Production - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Backend | Build Docker Production + run: docker compose -f docker-compose.yml build + + build-development: + if: needs.files-changed.outputs.changes == 'true' + name: Build Docker Development - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Backend | Build Docker Development + run: docker compose build \ No newline at end of file From cadc442a7e4325b4ddf9916916a7e231ecd8a2d7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Feb 2024 12:04:19 +0100 Subject: [PATCH 21/24] workflows --- .github/file-filters.yml | 7 +++ .../workflows/backend.test.build.docker.yml | 10 +++- .../workflows/presenter.test.build.docker.yml | 52 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/presenter.test.build.docker.yml diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 498232b290..c5abf87229 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -13,6 +13,10 @@ presenter-test-unit-code: &presenter-test-unit-code presenter-test-build-code: &presenter-test-build-code - 'presenter/**/*' +presenter-test-build-docker: &presenter-test-build-docker + - 'presenter/**/*' + + presenter-test-build-docs: &presenter-test-build-docs - 'presenter/**/*.md' - 'presenter/.vuepress/*' @@ -30,6 +34,9 @@ backend-test-unit-code: &backend-test-unit-code backend-test-build-code: &backend-test-build-code - 'backend/**/*' +backend-test-build-docker: &backend-test-build-docker + - 'backend/**/*' + backend-test-build-docs: &backend-test-build-docs - 'backend/**/*.md' - 'backend/.vuepress/*' \ No newline at end of file diff --git a/.github/workflows/backend.test.build.docker.yml b/.github/workflows/backend.test.build.docker.yml index 3fb35beda7..0ae68a629e 100644 --- a/.github/workflows/backend.test.build.docker.yml +++ b/.github/workflows/backend.test.build.docker.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Check for frontend file changes + - name: Check for backend file changes uses: dorny/paths-filter@v3.0.1 id: changes with: @@ -26,21 +26,27 @@ 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}} build-development: if: needs.files-changed.outputs.changes == '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 \ No newline at end of file + run: docker compose build + working-directory: ${{env.WORKING_DIRECTORY}} \ No newline at end of file diff --git a/.github/workflows/presenter.test.build.docker.yml b/.github/workflows/presenter.test.build.docker.yml new file mode 100644 index 0000000000..15e8cecd7d --- /dev/null +++ b/.github/workflows/presenter.test.build.docker.yml @@ -0,0 +1,52 @@ +name: "presenter:test:build test docker" + +on: push + +jobs: + # only (but most important) job from this workflow required for pull requests + # check results serve as run conditions for all other jobs here + files-changed: + name: Detect File Changes - presenter-test-build-docker + runs-on: ubuntu-latest + outputs: + changes: ${{ steps.changes.outputs.presenter-test-build-docker }} + steps: + - uses: actions/checkout@v4 + + - name: Check for presenter file changes + uses: dorny/paths-filter@v3.0.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + build-production: + if: needs.files-changed.outputs.changes == 'true' + 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}} + + build-development: + if: needs.files-changed.outputs.changes == '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}} \ No newline at end of file From b772bbec2282003ed140c52b9d433ebbf82dc507 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 6 Mar 2024 11:37:20 +0100 Subject: [PATCH 22/24] clean docker-compose files --- docker-compose.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index edac3052eb..2640ce98d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,12 +35,6 @@ services: 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 ####################################################### @@ -61,12 +55,6 @@ services: - 4000:4000 environment: - DATABASE_URL=mysql://root:@database:3306/dreammall.earth - # 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: From d02da2c03069a5ff8cbe6fcab04d5bda8e9dc16c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 6 Mar 2024 11:52:10 +0100 Subject: [PATCH 23/24] volumes --- docker-compose.override.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index df0e31a70e..3cfb5f3ccc 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -25,7 +25,7 @@ services: 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 - #- presenter_node_modules:/app/node_modules + - presenter_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -45,7 +45,7 @@ services: 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 - #- presenter_storybook_node_modules:/app/node_modules + - presenter_storybook_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -65,7 +65,7 @@ services: 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 - #- presenter_documentation_node_modules:/app/node_modules + - presenter_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -83,7 +83,7 @@ services: 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 + - backend_node_modules:/server/node_modules # bind the local folder to the docker to allow live reload - ./backend:/server @@ -103,7 +103,7 @@ services: 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_documentation_node_modules:/app/node_modules + - backend_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./backend:/server @@ -122,7 +122,7 @@ services: 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 + - documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./:/app @@ -131,4 +131,5 @@ volumes: presenter_storybook_node_modules: presenter_documentation_node_modules: backend_node_modules: + backend_documentation_node_modules: documentation_node_modules: \ No newline at end of file From 4acf60615228aa98c3706899e161faf9e60315cc Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 6 Mar 2024 12:05:45 +0100 Subject: [PATCH 24/24] remove volumes --- docker-compose.override.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 3cfb5f3ccc..a76e3ce025 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -25,7 +25,7 @@ services: 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 - - presenter_node_modules:/app/node_modules + #- presenter_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -45,7 +45,7 @@ services: 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 - - presenter_storybook_node_modules:/app/node_modules + #- presenter_storybook_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -65,7 +65,7 @@ services: 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 - - presenter_documentation_node_modules:/app/node_modules + #- presenter_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./presenter:/app @@ -83,7 +83,7 @@ services: 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 + #- backend_node_modules:/server/node_modules # bind the local folder to the docker to allow live reload - ./backend:/server @@ -103,7 +103,7 @@ services: 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_documentation_node_modules:/app/node_modules + #- backend_documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./backend:/server @@ -122,7 +122,7 @@ services: 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 + #- documentation_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./:/app