From d771eeb516c2338535c766e3d07a84291dd02a7a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 00:56:40 +0100 Subject: [PATCH 1/4] include dev dependencies in build phase --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6cbf431d02..dae836bb6d 100644 --- a/Dockerfile +++ b/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 From 82ae9f4f38035495bb52917ec934d537c2d2769d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 26 Feb 2024 01:06:21 +0100 Subject: [PATCH 2/4] workflow for building docker --- .github/file-filters.yml | 3 ++ .../workflows/frontend.test.build.docker.yml | 46 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/frontend.test.build.docker.yml diff --git a/.github/file-filters.yml b/.github/file-filters.yml index cbf23a2416..0a232f0a74 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -9,6 +9,9 @@ frontend-test-unit-code: &frontend-test-unit-code frontend-test-build-code: &frontend-test-build-code - '**/*' +frontend-test-build-docker: &frontend-test-build-docker + - '**/*' + frontend-test-build-docs: &frontend-test-build-docs - '**/*.md' - '.vuepress/*' diff --git a/.github/workflows/frontend.test.build.docker.yml b/.github/workflows/frontend.test.build.docker.yml new file mode 100644 index 0000000000..744671ac5e --- /dev/null +++ b/.github/workflows/frontend.test.build.docker.yml @@ -0,0 +1,46 @@ +name: "frontend: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 - frontend-test-build-docker + runs-on: ubuntu-latest + outputs: + changes: ${{ steps.changes.outputs.frontend-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 - Frontend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Frontend | Build Docker Production + run: docker compose -f docker-compose.yml build + + build-development: + if: needs.files-changed.outputs.changes == 'true' + name: Build Docker Development - Frontend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Frontend | Build Docker Development + run: docker compose build \ No newline at end of file From 47672bf28fabc373fd4b014117b204ed3733d8ac Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Feb 2024 11:50:49 +0100 Subject: [PATCH 3/4] adjust docker files according to new insights --- docker-compose.override.yml | 35 ++++++++++++++++++----------------- docker-compose.yml | 13 +++++-------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 4f3c1ecc97..4b2dde8c6f 100644 --- a/docker-compose.override.yml +++ b/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/docker-compose.yml b/docker-compose.yml index dbc715bd21..a084ff0a59 100644 --- a/docker-compose.yml +++ b/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 8765d7904f775793ae24fb11cf804bee863707ad Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Feb 2024 12:18:23 +0100 Subject: [PATCH 4/4] docker fixes --- .github/file-filters.yml | 3 ++ .../workflows/backend.test.build.docker.yml | 46 +++++++++++++++++++ Dockerfile | 2 +- docker-compose.override.yml | 29 ++++++++++-- docker-compose.yml | 13 ++---- prisma/schema.prisma | 1 + 6 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/backend.test.build.docker.yml diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 43bc6cd05a..41f3ae501b 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -9,6 +9,9 @@ backend-test-unit-code: &backend-test-unit-code backend-test-build-code: &backend-test-build-code - '**/*' +backend-test-build-docker: &backend-test-build-docker + - '**/*' + backend-test-build-docs: &backend-test-build-docs - '**/*.md' - '.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 new file mode 100644 index 0000000000..590a9ac944 --- /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 backend 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 diff --git a/Dockerfile b/Dockerfile index 34669e28d2..c2b66cdf3b 100644 --- a/Dockerfile +++ b/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 75ca26eba2..e6de57d442 100644 --- a/docker-compose.override.yml +++ b/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 @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index 2a40a57828..08583c9075 100644 --- a/docker-compose.yml +++ b/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: diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a68cbc186f..95b62fedb0 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { provider = "prisma-client-js" + binaryTargets = ["native", "linux-musl-openssl-3.0.x"] } datasource db {