automatically rebuild when switching config, allow reuse of already built images

This commit is contained in:
Ulf Gebhardt 2023-02-16 02:53:15 +01:00
parent fd223635d3
commit 101fd1bb41
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
5 changed files with 24 additions and 24 deletions

View File

@ -1 +1 @@
CONFIGURATION_FOLDER=configurations/example CONFIGURATION=example

View File

@ -16,13 +16,13 @@ services:
target: code target: code
webapp: webapp:
image: ocelotsocialnetwork/webapp-branded:local-production image: ocelotsocialnetwork/webapp-branded:local-${CONFIGURATION}
build: build:
dockerfile: src/docker/webapp.Dockerfile dockerfile: src/docker/webapp.Dockerfile
target: branded target: branded
context: . context: .
args: args:
- CONFIGURATION_FOLDER=$CONFIGURATION_FOLDER - CONFIGURATION=$CONFIGURATION
- APP_IMAGE_TAG_BASE=local-base - APP_IMAGE_TAG_BASE=local-base
- APP_IMAGE_TAG_CODE=local-code - APP_IMAGE_TAG_CODE=local-code
ports: ports:
@ -59,13 +59,13 @@ services:
target: code target: code
backend: backend:
image: ocelotsocialnetwork/backend-branded:local-production image: ocelotsocialnetwork/backend-branded:local-${CONFIGURATION}
build: build:
dockerfile: src/docker/backend.Dockerfile dockerfile: src/docker/backend.Dockerfile
target: branded target: branded
context: . context: .
args: args:
- CONFIGURATION_FOLDER=$CONFIGURATION_FOLDER - CONFIGURATION=$CONFIGURATION
- APP_IMAGE_TAG_BASE=local-base - APP_IMAGE_TAG_BASE=local-base
- APP_IMAGE_TAG_CODE=local-code - APP_IMAGE_TAG_CODE=local-code
networks: networks:
@ -113,14 +113,14 @@ services:
maintenance: maintenance:
# 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 # 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: ocelotsocialnetwork/maintenance-branded:local-production image: ocelotsocialnetwork/maintenance-branded:local-${CONFIGURATION}
build: build:
# TODO: Separate from webapp, this must be independent # TODO: Separate from webapp, this must be independent
dockerfile: src/docker/maintenance.Dockerfile dockerfile: src/docker/maintenance.Dockerfile
target: branded target: branded
context: . context: .
args: args:
- CONFIGURATION_FOLDER=$CONFIGURATION_FOLDER - CONFIGURATION=$CONFIGURATION
- APP_IMAGE_TAG_BASE=local-base - APP_IMAGE_TAG_BASE=local-base
- APP_IMAGE_TAG_CODE=local-code - APP_IMAGE_TAG_CODE=local-code
networks: networks:

View File

@ -9,13 +9,13 @@ ARG APP_IMAGE_CODE=${APP_IMAGE}:${APP_IMAGE_TAG_CODE}
################################################################################## ##################################################################################
FROM $APP_IMAGE_CODE as code FROM $APP_IMAGE_CODE as code
ARG CONFIGURATION_FOLDER=configurations/example ARG CONFIGURATION=example
# copy public constants and email templates into the Docker image to brand it # copy public constants and email templates into the Docker image to brand it
COPY ${CONFIGURATION_FOLDER}/branding/constants/emails.js src/config/ COPY configurations/${CONFIGURATION}/branding/constants/emails.js src/config/
COPY ${CONFIGURATION_FOLDER}/branding/constants/logos.js src/config/ COPY configurations/${CONFIGURATION}/branding/constants/logos.js src/config/
COPY ${CONFIGURATION_FOLDER}/branding/constants/metadata.js src/config/ COPY configurations/${CONFIGURATION}/branding/constants/metadata.js src/config/
COPY ${CONFIGURATION_FOLDER}/branding/email/ src/middleware/helpers/email/ COPY configurations/${CONFIGURATION}/branding/email/ src/middleware/helpers/email/
################################################################################## ##################################################################################
# BUILD ########################################################################## # BUILD ##########################################################################

View File

@ -9,12 +9,12 @@ ARG APP_IMAGE_CODE=${APP_IMAGE}:${APP_IMAGE_TAG_CODE}
################################################################################## ##################################################################################
FROM $APP_IMAGE_CODE as code FROM $APP_IMAGE_CODE as code
ARG CONFIGURATION_FOLDER=configurations/example ARG CONFIGURATION=example
# copy public constants into the Docker image to brand it # copy public constants into the Docker image to brand it
COPY ${CONFIGURATION_FOLDER}/branding/static/ static/ COPY configurations/${CONFIGURATION}/branding/static/ static/
COPY ${CONFIGURATION_FOLDER}/branding/constants/ constants/ COPY configurations/${CONFIGURATION}/branding/constants/ constants/
COPY ${CONFIGURATION_FOLDER}/branding/locales/ locales/ COPY configurations/${CONFIGURATION}/branding/locales/ locales/
################################################################################## ##################################################################################
# BUILD ########################################################################## # BUILD ##########################################################################

View File

@ -9,17 +9,17 @@ ARG APP_IMAGE_CODE=${APP_IMAGE}:${APP_IMAGE_TAG_CODE}
################################################################################## ##################################################################################
FROM $APP_IMAGE_CODE as code FROM $APP_IMAGE_CODE as code
ARG CONFIGURATION_FOLDER=configurations/example ARG CONFIGURATION=example
# copy public constants into the Docker image to brand it # copy public constants into the Docker image to brand it
COPY src/tools/ tools/ COPY src/tools/ tools/
COPY ${CONFIGURATION_FOLDER}/branding/static/ static/ COPY configurations/${CONFIGURATION}/branding/static/ static/
COPY ${CONFIGURATION_FOLDER}/branding/constants/ constants/ COPY configurations/${CONFIGURATION}/branding/constants/ constants/
COPY ${CONFIGURATION_FOLDER}/branding/locales/html/ locales/html/ COPY configurations/${CONFIGURATION}/branding/locales/html/ locales/html/
# COPY ${CONFIGURATION_FOLDER}/branding/locales/index.js locales/index.js # COPY configurations/${CONFIGURATION}/branding/locales/index.js locales/index.js
COPY ${CONFIGURATION_FOLDER}/branding/locales/*.json locales/tmp/ COPY configurations/${CONFIGURATION}/branding/locales/*.json locales/tmp/
COPY ${CONFIGURATION_FOLDER}/branding/assets/styles/imports/ assets/styles/imports/ COPY configurations/${CONFIGURATION}/branding/assets/styles/imports/ assets/styles/imports/
COPY ${CONFIGURATION_FOLDER}/branding/assets/fonts/ assets/fonts/ COPY configurations/${CONFIGURATION}/branding/assets/fonts/ assets/fonts/
RUN apk add --no-cache bash jq RUN apk add --no-cache bash jq