feat: unify on single repo-root compose file for dev and prod
Some checks failed
/ test (push) Has been cancelled
/ build (push) Has been cancelled
/ validate (push) Has been cancelled

This commit is contained in:
Jonas Miederer 2026-09-07 19:46:17 +00:00
parent 9acdbaa453
commit af993bd43f
18 changed files with 253 additions and 229 deletions

View file

@ -1,13 +1,13 @@
# Production image for the React UI (build + Vite preview; internal use).
# Frontend image for dev and prod (single image).
# Dev specifics arrive via devcontainer.json / compose env — never via this
# file. DevDeps are included: `npm run dev` must work with zero steps.
FROM node:22-slim
WORKDIR /srv/frontend
COPY package.json package-lock.json ./
RUN npm ci
WORKDIR /srv/kirche-einfach/frontend
COPY package.json package-lock.json entrypoint.sh ./
RUN npm ci && chmod +x entrypoint.sh
COPY . ./
RUN npm run build
ENV VITE_API_PROXY_TARGET=http://app:8000
EXPOSE 3000
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "3000"]
ENTRYPOINT ["./entrypoint.sh"]

14
frontend/entrypoint.sh Normal file
View file

@ -0,0 +1,14 @@
#!/bin/sh
# Frontend entrypoint (dev + prod).
# FRONTEND_MODE=dev (compose default) runs the HMR dev server.
# FRONTEND_MODE=preview (prod .env) builds once and serves the bundle.
set -e
cd /srv/kirche-einfach/frontend
if [ "${FRONTEND_MODE:-dev}" = "dev" ]; then
exec npm run dev -- --host 0.0.0.0 --port 3000
else
npm run build
exec npm run preview -- --host 0.0.0.0 --port 3000
fi

View file

@ -1,13 +1,15 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// Both dev server and preview proxy /api to the backend service.
// `api` is the compose service name, identical in dev and prod.
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
proxy: {
"/api": {
target: "http://localhost:8000",
target: "http://api:8000",
changeOrigin: true,
},
},
@ -16,8 +18,7 @@ export default defineConfig({
port: 3000,
proxy: {
"/api": {
// Overridable at container start (prod compose: http://app:8000).
target: process.env.VITE_API_PROXY_TARGET ?? "http://localhost:8000",
target: "http://api:8000",
changeOrigin: true,
},
},