fix docker

This commit is contained in:
einhornimmond 2025-01-21 12:09:59 +01:00
parent 79e726835f
commit cd739f56f5
7 changed files with 54 additions and 15 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
**/node_modules
**/build
**/coverage

View File

@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v3
- name: Admin Interface | Build 'test' image
run: docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test"
run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --no-deps admin
unit_test:
if: needs.files-changed.outputs.admin == 'true'

View File

@ -42,6 +42,8 @@ EXPOSE ${PORT}
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
RUN mkdir -p /config
##################################################################################
# DEVELOPMENT (Connected to the local environment, to reload on demand) ##########
##################################################################################
@ -53,7 +55,7 @@ FROM base as development
# Run command
# (for development we need to execute yarn install since the
# node_modules are on another volume and need updating)
CMD /bin/sh -c "yarn install && yarn run dev"
CMD /bin/sh -c "cd /config && yarn install && yarn build && cd /app && yarn install && yarn run dev"
##################################################################################
# BUILD (Does contain all files and is therefore bloated) ########################
@ -61,9 +63,15 @@ CMD /bin/sh -c "yarn install && yarn run dev"
FROM base as build
# Copy everything
COPY . .
# yarn install
COPY ./admin/ .
# Copy everything from config
COPY ./config/ ../config/
# yarn install admin
RUN yarn install --production=false --frozen-lockfile --non-interactive
# yarn install config
RUN cd ../config && yarn install --production=false --frozen-lockfile --non-interactive
RUN cd ../config && yarn build
# yarn build
RUN yarn run build
@ -85,6 +93,7 @@ FROM base as production
# Copy "binary"-files from build image
COPY --from=build ${DOCKER_WORKDIR}/build ./build
COPY --from=build ${DOCKER_WORKDIR}/../config/build ../config/build
# We also copy the node_modules express and serve-static for the run script
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
# Copy static files

14
config/.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
node_modules/
build/
.cache/
.yarn/install-state.gz
/.env
/.env.bak
# coverage folder
coverage/
# emacs
*~

View File

@ -7,7 +7,7 @@ services:
build:
target: test
environment:
- NODE_ENV="test"
- NODE_ENV=test
########################################################
# ADMIN INTERFACE ######################################
@ -17,7 +17,7 @@ services:
build:
target: test
environment:
- NODE_ENV="test"
- NODE_ENV=test
########################################################
# BACKEND ##############################################
@ -31,7 +31,7 @@ services:
- external-net
- internal-net
environment:
- NODE_ENV="test"
- NODE_ENV=test
- DB_HOST=mariadb
########################################################
@ -46,7 +46,7 @@ services:
- external-net
- internal-net
environment:
- NODE_ENV="test"
- NODE_ENV="test
- DB_HOST=mariadb
########################################################
@ -61,7 +61,7 @@ services:
- external-net
- internal-net
environment:
- NODE_ENV="test"
- NODE_ENV=test
- DB_HOST=mariadb
########################################################
@ -73,7 +73,7 @@ services:
context: ./database
target: test_up
environment:
- NODE_ENV="test"
- NODE_ENV=test
# restart: always # this is very dangerous, but worth a test for the delayed mariadb startup at first run
########################################################
@ -85,7 +85,7 @@ services:
context: ./dlt-database
target: test_up
environment:
- NODE_ENV="test"
- NODE_ENV=test
# restart: always # this is very dangerous, but worth a test for the delayed mariadb startup at first run
#########################################################

View File

@ -12,7 +12,8 @@ services:
# 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: gradido/frontend:local-production
build:
context: ./frontend
context: ./
dockerfile: ./frontend/Dockerfile
target: production
networks:
- external-net
@ -40,7 +41,8 @@ services:
# 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: gradido/admin:local-production
build:
context: ./admin
context: ./
dockerfile: ./admin/Dockerfile
target: production
networks:
- external-net

View File

@ -42,6 +42,8 @@ EXPOSE ${PORT}
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
RUN mkdir -p /config
##################################################################################
# DEVELOPMENT (Connected to the local environment, to reload on demand) ##########
##################################################################################
@ -53,7 +55,7 @@ FROM base as development
# 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 "yarn install && yarn run dev"
CMD /bin/sh -c "cd /config && yarn install && yarn build && cd /app && yarn install && yarn run dev"
##################################################################################
# BUILD (Does contain all files and is therefore bloated) ########################
@ -61,9 +63,17 @@ CMD /bin/sh -c "yarn install && yarn run dev"
FROM base as build
# Copy everything
COPY . .
COPY ./frontend ./
# Copy everything from config
COPY ./config/ ../config/
# npm install
RUN yarn global add node-gyp && yarn install --production=false --frozen-lockfile --non-interactive
# install and build config
RUN cd ../config && yarn install --production=false --frozen-lockfile --non-interactive
RUN cd ../config && yarn build
# npm build
RUN yarn run build
@ -85,6 +95,7 @@ FROM base as production
# Copy "binary"-files from build image
COPY --from=build ${DOCKER_WORKDIR}/build ./build
COPY --from=build ${DOCKER_WORKDIR}/../config/build ../config/build
# We also copy the node_modules express and serve-static for the run script
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
# Copy static files