From bc32ce5fc5fdfebbdb3b76cbe3bc1f9c1b1a9ea8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 30 May 2026 22:25:59 +0200 Subject: [PATCH] Add Docker support with runtime environment variable configuration - Remove temporary arne.js file - Add runtime configuration via window.__RUNTIME_CONFIG__ - Create public/config.template.js for hostname injection - Add Dockerfile with multi-stage build (node + nginx) - Add docker-entrypoint.sh to generate config.js at startup - Add .dockerignore - Update all components to use runtime config instead of arne.js - Update index.html to load config.js before app This allows deploying the same Docker image to different environments by setting the API_HOSTNAME environment variable at runtime. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- .dockerignore | 4 ++++ Dockerfile | 18 ++++++++++++++++++ docker-entrypoint.sh | 8 ++++++++ public/config.template.js | 3 +++ public/index.html | 1 + src/arne.js | 3 --- src/components/items/InspirationWindow.vue | 3 +-- src/components/items/extraButtons.vue | 5 ++--- src/components/layout/TheFooter.vue | 15 +++++++-------- 9 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-entrypoint.sh create mode 100644 public/config.template.js delete mode 100644 src/arne.js diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7e134bd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.git +dist +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..21850af --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Build stage +FROM node:18-alpine AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Runtime stage +FROM nginx:alpine +RUN apk add --no-cache gettext +COPY --from=builder /app/dist /usr/share/nginx/html +COPY public/config.template.js /usr/share/nginx/html/ +COPY docker-entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..b90ac9c --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Generate config.js from template at runtime +envsubst < /usr/share/nginx/html/config.template.js > /usr/share/nginx/html/config.js + +# Start nginx +exec "$@" diff --git a/public/config.template.js b/public/config.template.js new file mode 100644 index 0000000..0d796f2 --- /dev/null +++ b/public/config.template.js @@ -0,0 +1,3 @@ +window.__RUNTIME_CONFIG__ = { + API_HOSTNAME: '${API_HOSTNAME}' +}; diff --git a/public/index.html b/public/index.html index 6be1946..3e41c11 100644 --- a/public/index.html +++ b/public/index.html @@ -8,6 +8,7 @@ <%= htmlWebpackPlugin.options.title %> +