From 7fafb546b5eb8fdb0932844f243b82ed3ab49638 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 20 Jan 2025 17:00:51 +0100 Subject: [PATCH] fix docker setup --- admin/src/components/NavBar.spec.js | 2 +- admin/src/components/NavBar.vue | 2 +- backend/Dockerfile | 17 ++++++++++++++--- database/src/config/detectLastDBVersion.ts | 4 ++-- dht-node/Dockerfile | 13 ++++++++++++- docker-compose.override.yml | 15 +++++++++++++++ federation/Dockerfile | 13 ++++++++++++- 7 files changed, 57 insertions(+), 9 deletions(-) diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index b88e0d2fe..c6a63db84 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -114,7 +114,7 @@ describe('NavBar', () => { it('changes window location to wallet and dispatches logout', async () => { const dispatchSpy = vi.spyOn(store, 'dispatch') await wrapper.vm.handleWallet() - expect(window.location).toBe(CONFIG.WALLET_AUTH_URL.replace('{token}', 'valid-token')) + expect(window.location).toBe(CONFIG.WALLET_AUTH_URL + 'valid-token') expect(dispatchSpy).toHaveBeenCalledWith('logout') }) }) diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index dc0f7828a..b9dc12106 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -80,7 +80,7 @@ const handleLogout = async () => { } const handleWallet = () => { - window.location = CONFIG.WALLET_AUTH_URL.replace('{token}', store.state.token) + window.location = CONFIG.WALLET_AUTH_URL + store.state.token store.dispatch('logout') // logout without redirect } diff --git a/backend/Dockerfile b/backend/Dockerfile index 910bdd504..8bf65e300 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -43,6 +43,7 @@ RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} RUN mkdir -p /database +RUN mkdir -p /config ################################################################################## # DEVELOPMENT (Connected to the local environment, to reload on demand) ########## @@ -55,7 +56,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 "cd /database && yarn install && yarn build && cd /app && yarn install && yarn run dev" +CMD /bin/sh -c "cd /config && yarn install && yarn build && cd /database && yarn install && yarn build && cd /app && yarn install && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## @@ -66,6 +67,8 @@ FROM base as build COPY ./backend/ ./ # Copy everything from database COPY ./database/ ../database/ +# Copy everything from config +COPY ./config/ ../config/ # yarn install backend RUN yarn install --production=false --frozen-lockfile --non-interactive @@ -73,11 +76,17 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn install database RUN cd ../database && yarn install --production=false --frozen-lockfile --non-interactive +# yarn install config +RUN cd ../config && yarn install --production=false --frozen-lockfile --non-interactive + # yarn build -RUN yarn run build +RUN yarn build # yarn build database -RUN cd ../database && yarn run build +RUN cd ../database && yarn build + +# yarn build config +RUN cd ../config && yarn build ################################################################################## # TEST ########################################################################### @@ -95,9 +104,11 @@ FROM base as production # Copy "binary"-files from build image COPY --from=build ${DOCKER_WORKDIR}/build ./build COPY --from=build ${DOCKER_WORKDIR}/../database/build ../database/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 --from=build ${DOCKER_WORKDIR}/../database/node_modules ../database/node_modules +COPY --from=build ${DOCKER_WORKDIR}/../config/node_modules ../config/node_modules # Copy static files # COPY --from=build ${DOCKER_WORKDIR}/public ./public diff --git a/database/src/config/detectLastDBVersion.ts b/database/src/config/detectLastDBVersion.ts index 4ec55b5f4..bc9e7766e 100644 --- a/database/src/config/detectLastDBVersion.ts +++ b/database/src/config/detectLastDBVersion.ts @@ -5,8 +5,8 @@ import fs from 'fs' const DB_VERSION_PATTERN = /^(\d{4}-[a-z0-9-_]+)/ // Define the paths to check -const migrationsDir = path.join(__dirname, '..', '..', '..', 'migrations') -const entitiesDir = path.join(__dirname, '..', '..', '..', 'entity') +const migrationsDir = path.join(__dirname, '..', '..', 'migrations') +const entitiesDir = path.join(__dirname, '..', '..', 'entity') // Helper function to get the highest version number from the directory function getLatestDbVersion(dir: string): string { diff --git a/dht-node/Dockerfile b/dht-node/Dockerfile index 9f1bbabf7..899a4a980 100644 --- a/dht-node/Dockerfile +++ b/dht-node/Dockerfile @@ -47,6 +47,7 @@ RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} RUN mkdir -p /database +RUN mkdir -p /config ################################################################################## # DEVELOPMENT (Connected to the local environment, to reload on demand) ########## @@ -59,7 +60,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 "cd /database && yarn install && yarn build && cd /app && yarn install && yarn run dev" +CMD /bin/sh -c "cd /config && yarn install && yarn build && cd /database && yarn install && yarn build && cd /app && yarn install && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## @@ -70,6 +71,8 @@ FROM base as build COPY ./dht-node/ ./ # Copy everything from database COPY ./database/ ../database/ +# Copy everything from config +COPY ./config/ ../config/ # yarn install dht-node RUN yarn install --production=false --frozen-lockfile --non-interactive @@ -77,12 +80,18 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn install database RUN cd ../database && yarn install --production=false --frozen-lockfile --non-interactive +# yarn install config +RUN cd ../config && yarn install --production=false --frozen-lockfile --non-interactive + # yarn build RUN yarn run build # yarn build database RUN cd ../database && yarn run build +# yarn build config +RUN cd ../config && yarn run build + ################################################################################## # TEST ########################################################################### ################################################################################## @@ -99,9 +108,11 @@ FROM base as production # Copy "binary"-files from build image COPY --from=build ${DOCKER_WORKDIR}/build ./build COPY --from=build ${DOCKER_WORKDIR}/../database/build ../database/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 --from=build ${DOCKER_WORKDIR}/../database/node_modules ../database/node_modules +COPY --from=build ${DOCKER_WORKDIR}/../config/node_modules ../config/node_modules # Copy static files # COPY --from=build ${DOCKER_WORKDIR}/public ./public diff --git a/docker-compose.override.yml b/docker-compose.override.yml index a15555ea1..e8c2d4d90 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -55,9 +55,12 @@ services: - backend_node_modules:/app/node_modules - backend_database_node_modules:/database/node_modules - backend_database_build:/database/build + - backend_config_node_modules:/config/node_modules + - backend_config_build:/config/build # bind the local folder to the docker to allow live reload - ./backend:/app - ./database:/database + - ./config:/config ######################################################## # DHT-NODE ############################################# @@ -78,9 +81,12 @@ services: - dht_node_modules:/app/node_modules - dht_database_node_modules:/database/node_modules - dht_database_build:/database/build + - dht_config_node_modules:/config/node_modules + - dht_config_build:/config/build # bind the local folder to the docker to allow live reload - ./dht-node:/app - ./database:/database + - ./config:/config ######################################################## # DLT-CONNECTOR ######################################## @@ -122,9 +128,12 @@ services: - federation_node_modules:/app/node_modules - federation_database_node_modules:/database/node_modules - federation_database_build:/database/build + - federation_config_node_modules:/config/node_modules + - federation_config_build:/config/build # bind the local folder to the docker to allow live reload - ./federation:/app - ./database:/database + - ./config:/config ######################################################## # DATABASE ############################################## @@ -216,13 +225,19 @@ volumes: backend_node_modules: backend_database_node_modules: backend_database_build: + backend_config_node_modules: + backend_config_build: dht_node_modules: dht_database_node_modules: dht_database_build: + dht_config_node_modules: + dht_config_build: dlt_connector_modules: federation_node_modules: federation_database_node_modules: federation_database_build: + federation_config_node_modules: + federation_config_build: database_node_modules: database_build: dlt-database_node_modules: diff --git a/federation/Dockerfile b/federation/Dockerfile index 81b95010e..a6f95bf3b 100644 --- a/federation/Dockerfile +++ b/federation/Dockerfile @@ -44,6 +44,7 @@ RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} RUN mkdir -p /database +RUN mkdir -p /config ################################################################################## # DEVELOPMENT (Connected to the local environment, to reload on demand) ########## @@ -56,7 +57,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 "cd /database && yarn install && yarn build && cd /app && yarn install && yarn run dev" +CMD /bin/sh -c "cd /config && yarn install && yarn build && cd /database && yarn install && yarn build && cd /app && yarn install && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## @@ -67,6 +68,8 @@ FROM base as build COPY ./federation/ ./ # Copy everything from database COPY ./database/ ../database/ +# Copy everything from config +COPY ./config/ ../config/ # yarn install federation RUN yarn install --production=false --frozen-lockfile --non-interactive @@ -74,12 +77,18 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn install database RUN cd ../database && yarn install --production=false --frozen-lockfile --non-interactive +# yarn install config +RUN cd ../config && yarn install --production=false --frozen-lockfile --non-interactive + # yarn build RUN yarn run build # yarn build database RUN cd ../database && yarn run build +# yarn build config +RUN cd ../config && yarn run build + ################################################################################## # TEST ########################################################################### ################################################################################## @@ -96,9 +105,11 @@ FROM base as production # Copy "binary"-files from build image COPY --from=build ${DOCKER_WORKDIR}/build ./build COPY --from=build ${DOCKER_WORKDIR}/../database/build ../database/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 --from=build ${DOCKER_WORKDIR}/../database/node_modules ../database/node_modules +COPY --from=build ${DOCKER_WORKDIR}/../config/node_modules ../config/node_modules # Copy static files # COPY --from=build ${DOCKER_WORKDIR}/public ./public