Files

30 lines
947 B
Docker

# Stage 1: build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --prefer-offline
COPY . .
# Vite bakes these in at build time — they're not readable at container
# runtime, so the compose service must pass them as build args.
ARG VITE_CORE_URL
ARG VITE_PRODUCTION_URL
ENV VITE_CORE_URL=$VITE_CORE_URL
ENV VITE_PRODUCTION_URL=$VITE_PRODUCTION_URL
RUN npm run build
# Stage 2: serve with Caddy
FROM caddy:2-alpine
# The caddy binary in this base image already carries the
# cap_net_bind_service file capability (setcap'd at image build time), so a
# non-root user can still bind :80 — only /config and /data (Caddy's
# XDG state dirs, set via env in the base image) need to be writable by it.
RUN addgroup -S caddy && adduser -S -G caddy caddy \
&& chown -R caddy:caddy /config /data
COPY --from=builder --chown=caddy:caddy /app/dist /srv
COPY --chown=caddy:caddy Caddyfile /etc/caddy/Caddyfile
USER caddy