diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 43bc6cd..41f3ae5 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 0000000..590a9ac --- /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 34669e2..c2b66cd 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 75ca26e..e6de57d 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 2a40a57..08583c9 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 a68cbc1..95b62fe 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 {