From 657ce4ed4049dcb93b1a975721afb517bf8d00a4 Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Wed, 21 May 2025 13:31:28 +0200 Subject: [PATCH] build: update Dockerfile for dynamic env configuration --- frontend/.docker/Dockerfile | 48 ++++++++++++++++++------ frontend/docker-entrypoint.sh | 8 ++++ frontend/env.js | 8 ++++ frontend/src/environments/environment.ts | 15 +++++++- frontend/src/index.html | 1 + 5 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 frontend/docker-entrypoint.sh create mode 100644 frontend/env.js diff --git a/frontend/.docker/Dockerfile b/frontend/.docker/Dockerfile index 494c91f..2f75a70 100644 --- a/frontend/.docker/Dockerfile +++ b/frontend/.docker/Dockerfile @@ -1,23 +1,47 @@ -FROM oven/bun:debian AS build +# Build stage +FROM oven/bun:latest as build + WORKDIR /app -RUN apt-get update -y && apt-get install nodejs -y - -ENV NODE_ENV=production - +# Copy package.json and bun.lock COPY package.json bun.lock ./ -RUN bun install --frozen-lockfile +# Install dependencies +RUN bun install + +# Copy the rest of the app COPY . . + +# Build the app RUN bun run build -FROM nginx:alpine AS production +# Production stage +FROM nginx:alpine -RUN rm /etc/nginx/conf.d/default.conf -COPY .docker/casino.conf /etc/nginx/templates/nginx.conf.template -COPY .docker/entrypoint.sh /docker-entrypoint.d/40-custom-config-env.sh +# Copy custom nginx config if needed +# COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=build /app/dist/casino /usr/share/nginx/html +# Copy the build output +COPY --from=build /app/dist/browser /usr/share/nginx/html + +# Copy the env.js file +COPY --from=build /app/env.js /usr/share/nginx/html/env.js + +# Copy the entrypoint script +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + +# Install envsubst +RUN apk add --no-cache gettext + +# Update index.html to load env.js before the app +RUN sed -i 's// Trustworthy Casino