Files
nats-svelte-demo/web/Dockerfile
2025-10-23 19:08:19 +07:00

27 lines
840 B
Docker

# Builder: build the SvelteKit static site (adapter-static -> /app/build)
FROM node:20-alpine AS builder
WORKDIR /app
# cache package install
COPY package.json package-lock.json* ./
RUN npm ci --production=false
# copy source and build
COPY . .
RUN npm run build
# Final: lightweight Caddy image to serve the built static files
FROM caddy:2-alpine AS runtime
# copy built static output
COPY --from=builder /app/build /srv/web_build
# copy Caddyfile from build context (provide Caddyfile at ./web/Caddyfile)
COPY Caddyfile /etc/caddy/Caddyfile
# # ensure permissions (caddy runs as non-root)
# RUN chown -R caddy:caddy /srv/web_build /etc/caddy/Caddyfile
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]
# expose standard HTTP/HTTPS (optional in compose)
EXPOSE 80
# container runs Caddy by default (CMD provided by base image)