docker fixes

This commit is contained in:
Ulf Gebhardt 2024-02-27 12:18:23 +01:00
parent d38f8e0125
commit 8765d7904f
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
6 changed files with 80 additions and 14 deletions

View File

@ -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/*'

View File

@ -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

View File

@ -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) ########################

View File

@ -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:

View File

@ -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:

View File

@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {