From dc3d56eb0f1632942a3231a9ea72a53d60a94699 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Sun, 26 Jan 2025 20:03:16 +0100 Subject: [PATCH] fix problems with dev container --- admin/Dockerfile | 2 +- admin/src/config/schema.js | 2 -- admin/vite.config.js | 24 ++++++++++-------------- backend/Dockerfile | 2 +- config/src/commonSchema.ts | 11 +++++++++-- config/src/index.ts | 12 ++++++++---- dht-node/Dockerfile | 2 +- federation/Dockerfile | 2 +- frontend/src/config/schema.js | 2 -- frontend/vite.config.js | 23 ++++++++++------------- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/admin/Dockerfile b/admin/Dockerfile index 2678c7c29..7d06b8251 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -55,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 "cd /config && yarn install && yarn build && cd /app && yarn install && yarn run dev" +CMD /bin/sh -c "cd /config && yarn install && cd /app && yarn && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## diff --git a/admin/src/config/schema.js b/admin/src/config/schema.js index 2fa938200..7aee8136f 100644 --- a/admin/src/config/schema.js +++ b/admin/src/config/schema.js @@ -1,5 +1,4 @@ const { - browserUrls, APP_VERSION, BUILD_COMMIT, BUILD_COMMIT_SHORT, @@ -12,7 +11,6 @@ const { const Joi = require('joi') module.exports = Joi.object({ - browserUrls, APP_VERSION, BUILD_COMMIT, BUILD_COMMIT_SHORT, diff --git a/admin/vite.config.js b/admin/vite.config.js index a889b664b..bd05d1f58 100644 --- a/admin/vite.config.js +++ b/admin/vite.config.js @@ -7,7 +7,7 @@ import IconsResolve from 'unplugin-icons/resolver' import { BootstrapVueNextResolver } from 'bootstrap-vue-next' import EnvironmentPlugin from 'vite-plugin-environment' import schema from './src/config/schema' -import { validate } from 'gradido-config/build/src/index.js' +import { validate, browserUrls } from 'gradido-config/build/src/index.js' import dotenv from 'dotenv' @@ -24,19 +24,15 @@ export default defineConfig(({ command }) => { CONFIG.ADMIN_HOSTING = 'nginx' } // Check config - const configDataForValidation = { - ...CONFIG, - // make sure that all urls used in browser have the same protocol to prevent mixed content errors - browserUrls: [ - CONFIG.WALLET_AUTH_URL, - CONFIG.COMMUNITY_URL, - CONFIG.WALLET_LOGIN_URL, - CONFIG.GRAPHQL_URI, - CONFIG.ADMIN_MODULE_URL, - ], - } - - validate(schema, configDataForValidation) + validate(schema, CONFIG) + // make sure that all urls used in browser have the same protocol to prevent mixed content errors + validate(browserUrls, [ + CONFIG.ADMIN_AUTH_URL, + CONFIG.COMMUNITY_URL, + CONFIG.COMMUNITY_REGISTER_URL, + CONFIG.GRAPHQL_URI, + CONFIG.FRONTEND_MODULE_URL, + ]) return { base: '/admin/', diff --git a/backend/Dockerfile b/backend/Dockerfile index d8b415e47..b755ecd38 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -56,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 /config && yarn build && ls ./build/ && cd /app && ls -la ../config/build && yarn install && yarn run dev" +CMD /bin/sh -c "cd /database && yarn install && yarn build && cd /config && yarn install && cd /app && yarn install && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## diff --git a/config/src/commonSchema.ts b/config/src/commonSchema.ts index 46264217b..484d4bab6 100644 --- a/config/src/commonSchema.ts +++ b/config/src/commonSchema.ts @@ -2,10 +2,17 @@ import Joi from 'joi' export const browserUrls = Joi.array() .items(Joi.string().uri()) + .sparse(true) .custom((value: string[], helpers: Joi.CustomHelpers) => { - const protocol = new URL(value[0]).protocol + let protocol: string | undefined for (const url of value) { - if (new URL(url).protocol !== protocol) { + if (url === undefined) { + continue + } + const urlObject = new URL(url) + if(!protocol) { + protocol = urlObject.protocol + } else if(urlObject.protocol !== protocol) { return helpers.error('any.invalid') } } diff --git a/config/src/index.ts b/config/src/index.ts index 04e096d0a..9137ead6d 100644 --- a/config/src/index.ts +++ b/config/src/index.ts @@ -6,19 +6,23 @@ export function validate(schema: ObjectSchema, data: any) { const schemaJson = schema.describe() if (error) { error.details.forEach((err) => { + const details = JSON.stringify(err, null, 2) if (!err.context) { - throw new Error('missing context in config validation with joi') + throw new Error('missing context in config validation with joi: ' + details) + } + if (!schemaJson) { + throw new Error('invalid schema in config validation with joi: ' + details) } const key = err.context.key - if (!key) { - throw new Error('missing key in config validation with joi') + if (key === undefined) { + throw new Error('missing key in config validation with joi: ' + details) } const value = err.context.value const description = schemaJson.keys[key] ? schema.describe().keys[key].flags.description : 'No description available' if (data[key] === undefined) { - throw new Error(`Environment Variable '${key}' is missing. ${description}`) + throw new Error(`Environment Variable '${key}' is missing. ${description}, details: ${details}`) } else { throw new Error( `Error on Environment Variable ${key} with value = ${value}: ${err.message}. ${description}`, diff --git a/dht-node/Dockerfile b/dht-node/Dockerfile index 7b2aa6ad7..6e35176a3 100644 --- a/dht-node/Dockerfile +++ b/dht-node/Dockerfile @@ -60,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 /config && yarn build && cd /app && yarn install && yarn run dev" +CMD /bin/sh -c "cd /database && yarn install && yarn build && cd /config && yarn install && cd /app && yarn install && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## diff --git a/federation/Dockerfile b/federation/Dockerfile index 6cc70e2b0..26c83ad7b 100644 --- a/federation/Dockerfile +++ b/federation/Dockerfile @@ -57,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 /config && yarn build && cd /app && yarn install && yarn run dev" +CMD /bin/sh -c "cd /database && yarn install && yarn build && cd /config && yarn install && cd /app && yarn install && yarn run dev" ################################################################################## # BUILD (Does contain all files and is therefore bloated) ######################## diff --git a/frontend/src/config/schema.js b/frontend/src/config/schema.js index fdae0ae0d..dc5a22c43 100644 --- a/frontend/src/config/schema.js +++ b/frontend/src/config/schema.js @@ -1,5 +1,4 @@ const { - browserUrls, APP_VERSION, BUILD_COMMIT, BUILD_COMMIT_SHORT, @@ -21,7 +20,6 @@ const Joi = require('joi') // console.log(commonSchema) module.exports = Joi.object({ - browserUrls, APP_VERSION, BUILD_COMMIT, BUILD_COMMIT_SHORT, diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 53d3a2796..2385e92ef 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -8,7 +8,7 @@ import IconsResolve from 'unplugin-icons/resolver' import EnvironmentPlugin from 'vite-plugin-environment' import { createHtmlPlugin } from 'vite-plugin-html' import schema from './src/config/schema' -import { validate } from 'gradido-config/build/src/index.js' +import { validate, browserUrls } from 'gradido-config/build/src/index.js' import { BootstrapVueNextResolver } from 'bootstrap-vue-next' import dotenv from 'dotenv' @@ -25,18 +25,15 @@ export default defineConfig(({ command }) => { CONFIG.FRONTEND_HOSTING = 'nginx' } // Check config - const configDataForValidation = { - ...CONFIG, - // make sure that all urls used in browser have the same protocol to prevent mixed content errors - browserUrls: [ - CONFIG.ADMIN_AUTH_URL, - CONFIG.COMMUNITY_URL, - CONFIG.COMMUNITY_REGISTER_URL, - CONFIG.GRAPHQL_URI, - CONFIG.FRONTEND_MODULE_URL, - ], - } - validate(schema, configDataForValidation) + validate(schema, CONFIG) + // make sure that all urls used in browser have the same protocol to prevent mixed content errors + validate(browserUrls, [ + CONFIG.ADMIN_AUTH_URL, + CONFIG.COMMUNITY_URL, + CONFIG.COMMUNITY_REGISTER_URL, + CONFIG.GRAPHQL_URI, + CONFIG.FRONTEND_MODULE_URL, + ]) return { server: {