Skip to content

Commit

Permalink
Merge pull request #21 from IT4Change/docker-updates
Browse files Browse the repository at this point in the history
fix(backend): docker fixes
  • Loading branch information
ulfgebhardt authored Feb 27, 2024
2 parents d38f8e0 + 8765d79 commit f8d02b3
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*'
46 changes: 46 additions & 0 deletions .github/workflows/backend.test.build.docker.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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) ########################
Expand Down
29 changes: 24 additions & 5 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
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
- 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:
13 changes: 5 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}

datasource db {
Expand Down

0 comments on commit f8d02b3

Please sign in to comment.