From 600421a30fd52d0276105e1f558e6b535ebe35d0 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 14 Aug 2025 13:51:38 +0200 Subject: [PATCH] fix database dockerfile, test it correct in tests --- .github/workflows/test_database.yml | 2 +- database/Dockerfile | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test_database.yml b/.github/workflows/test_database.yml index 2c1a7ef94..e0b52d149 100644 --- a/.github/workflows/test_database.yml +++ b/.github/workflows/test_database.yml @@ -32,7 +32,7 @@ jobs: uses: actions/checkout@v3 - name: Database | Build image - run: docker build --target build -t "gradido/database:build" -f database/Dockerfile . + run: docker build --target up -t "gradido/database:up" -f database/Dockerfile . database_migration_test: if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' || needs.files-changed.outputs.shared == 'true' diff --git a/database/Dockerfile b/database/Dockerfile index 5413b891b..cbcaddc73 100644 --- a/database/Dockerfile +++ b/database/Dockerfile @@ -56,27 +56,32 @@ ENV PATH="/root/.bun/bin:${PATH}" FROM bun-base as installer COPY --chown=app:app . . -RUN bun install --filter database --production --no-cache --frozen-lockfile + +################################################################################## +# Build Shared ################################################################### +################################################################################## +FROM installer as build-shared + +RUN bun install --filter shared --no-cache --frozen-lockfile \ + && cd shared && yarn typecheck && yarn build ################################################################################## # Build ########################################################################## ################################################################################## FROM installer as build -RUN bun install --no-cache --frozen-lockfile \ - && cd shared && yarn build \ - && cd ../database && yarn build && yarn typecheck +RUN bun install --filter database --production --no-cache --frozen-lockfile ################################################################################## # PRODUCTION IMAGE ############################################################### ################################################################################## FROM base as production -COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/src ./src -COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/migration ./migration -COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/node_modules ./node_modules -COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/package.json ./package.json -COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/tsconfig.json ./tsconfig.json +COPY --chown=app:app --from=build-shared ${DOCKER_WORKDIR}/shared/build ./shared/build +COPY --chown=app:app --from=build-shared ${DOCKER_WORKDIR}/shared/package.json ./shared/package.json +COPY --chown=app:app --from=build ${DOCKER_WORKDIR}/database ./database +COPY --chown=app:app --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules +COPY --chown=app:app --from=build ${DOCKER_WORKDIR}/package.json ./package.json ################################################################################## # TEST UP ######################################################################## @@ -84,7 +89,7 @@ COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/tsconfig.json ./tsconfig FROM production as up # Run command -CMD /bin/sh -c "yarn up" +CMD /bin/sh -c "cd database && yarn up" ################################################################################## # TEST RESET ##################################################################### @@ -92,7 +97,7 @@ CMD /bin/sh -c "yarn up" FROM production as reset # Run command -CMD /bin/sh -c "yarn reset" +CMD /bin/sh -c "cd database && yarn reset" ################################################################################## # TEST DOWN ###################################################################### @@ -100,4 +105,4 @@ CMD /bin/sh -c "yarn reset" FROM production as down # Run command -CMD /bin/sh -c "yarn down" +CMD /bin/sh -c "cd database && yarn down"