- Switch frontend from nginx to caddy for consistency with Coolify - Make VITE_API_URL optional, auto-derive from window.location.origin/api - Simplifies deployment by not requiring build-time API URL Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
525 B
Docker
33 lines
525 B
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
|
|
# VITE_API_URL must be set at build time
|
|
ARG VITE_API_URL
|
|
ENV VITE_API_URL=${VITE_API_URL}
|
|
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM caddy:alpine
|
|
|
|
# Copy built assets
|
|
COPY --from=builder /app/dist /srv
|
|
|
|
# Caddyfile for SPA routing
|
|
RUN echo ':8080 { \
|
|
root * /srv \
|
|
file_server \
|
|
try_files {path} /index.html \
|
|
}' > /etc/caddy/Caddyfile
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]
|