diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 874ace92..6243fb71 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -13,6 +13,7 @@ COPY . . ENV VITE_RUN_CONFIG=${VITE_RUN_CONFIG} ENV VITE_SERVER_URL_HTTP=${VITE_SERVER_URL_HTTP} ENV VITE_SERVER_URL_WS=${VITE_SERVER_URL_WS} +ENV IS_DOCKER=TRUE ENV PORT=5173 EXPOSE 5173 RUN if [ "$VITE_RUN_CONFIG" = "prod" ]; then npm run build-only; fi diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index b8cb2155..59938818 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -3,6 +3,12 @@ import {fileURLToPath, URL} from 'node:url' import {defineConfig} from 'vite' import vue from '@vitejs/plugin-vue' +function isNotDocker() { + const b = !process.env.IS_DOCKER + console.log('isDocker:', b) + return b +} + // https://vitejs.dev/config/ export default defineConfig({ plugins: [ @@ -19,11 +25,7 @@ export default defineConfig({ 'process.env': process.env }, server: { - // in order for hot module replacement to not throw an error inside the docker container - // (localhost would resolve to the container and not the host) - hmr: { - host: 'ws://host.docker.internal', - port: 80 - } + // we do not need hmr in docker images + default address would not work (host: 'host.docker.internal' would be needed) + hmr: isNotDocker(), } })