- Add Cache-Control: no-cache as default so browsers revalidate via ETag instead of heuristic caching stale llms.txt and HTML pages - Fix hashed asset path from /docs/_astro/* to /_astro/* (root is /srv) - _astro/* immutable rule still applies for hashed Vite bundles
63 lines
1.5 KiB
Docker
63 lines
1.5 KiB
Docker
ARG NODE_VERSION=22
|
|
|
|
# ── Stage 1: Build ──────────────────────────────────────────────
|
|
FROM node:${NODE_VERSION}-slim AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies first (cache layer)
|
|
COPY package.json package-lock.json ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci
|
|
|
|
# Copy source and build
|
|
COPY . .
|
|
ENV ASTRO_TELEMETRY_DISABLED=1
|
|
RUN npm run build
|
|
|
|
# ── Stage 2: Production ────────────────────────────────────────
|
|
FROM caddy:2-alpine AS production
|
|
|
|
COPY --from=build /app/dist /srv
|
|
COPY <<'CADDYFILE' /etc/caddy/Caddyfile
|
|
:3000 {
|
|
root * /srv
|
|
file_server
|
|
try_files {path} {path}/ /404.html
|
|
encode gzip
|
|
|
|
header {
|
|
X-Content-Type-Options nosniff
|
|
X-Frame-Options DENY
|
|
Referrer-Policy strict-origin-when-cross-origin
|
|
Cache-Control "no-cache"
|
|
}
|
|
|
|
header /_astro/* {
|
|
Cache-Control "public, max-age=31536000, immutable"
|
|
}
|
|
}
|
|
CADDYFILE
|
|
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
|
CMD wget -qO- http://127.0.0.1:3000/ || exit 1
|
|
|
|
# ── Stage 3: Development ───────────────────────────────────────
|
|
FROM node:${NODE_VERSION}-slim AS development
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci
|
|
|
|
COPY . .
|
|
|
|
ENV ASTRO_TELEMETRY_DISABLED=1
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["npm", "run", "dev"]
|