Files
gw-svelte/Dockerfile
T

51 lines
1.7 KiB
Docker
Raw Normal View History

2026-05-26 08:30:08 +12:00
# syntax=docker/dockerfile:1.7
2026-05-19 23:36:58 +12:00
ARG APP_VERSION=4.0.1
2026-05-02 19:44:45 +12:00
2026-05-02 08:26:18 +12:00
FROM node:22-alpine AS builder
2026-05-02 19:44:45 +12:00
ARG APP_VERSION
2026-05-02 08:26:18 +12:00
WORKDIR /app
2026-05-26 08:30:08 +12:00
# 1. Dependencies — only re-runs when package*.json change.
COPY package.json package-lock.json ./
2026-05-18 22:25:43 +12:00
RUN npm ci
2026-05-02 08:26:18 +12:00
2026-05-26 08:30:08 +12:00
# 2. Image assets in their own layer. Enhanced-img content-hashes its inputs,
# so when these files are unchanged the BuildKit cache mount below replays
# the previous WebP/AVIF outputs instead of regenerating them.
COPY src/lib/images ./src/lib/images
COPY static ./static
# 3. Build config (changes rarely).
COPY svelte.config.js vite.config.ts tsconfig.json ./
# 4. Everything else. Component-only edits invalidate this layer but the vite
# transform cache below keeps the expensive image pipeline warm.
2026-05-02 08:26:18 +12:00
COPY . .
2026-05-26 08:30:08 +12:00
2026-05-12 00:45:02 +12:00
RUN node --experimental-strip-types --import="file:///app/scripts/sveltekit-resolver.mjs" scripts/export-homepage-content.mjs
2026-05-26 08:30:08 +12:00
# Persist vite's transform cache across builds. Enhanced-img stores its
# generated raster variants here keyed by source-image hash, so unchanged
# images skip the sharp/resize/encode pass entirely.
RUN --mount=type=cache,target=/app/node_modules/.vite,sharing=locked \
npm run build
2026-05-02 08:26:18 +12:00
FROM node:22-alpine AS runner
2026-05-02 19:44:45 +12:00
ARG APP_VERSION
2026-05-02 08:26:18 +12:00
WORKDIR /app
ENV NODE_ENV=production
2026-05-02 19:44:45 +12:00
ENV APP_VERSION=${APP_VERSION}
LABEL org.opencontainers.image.version="${APP_VERSION}"
2026-05-02 08:26:18 +12:00
COPY --from=builder /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/build ./build
2026-05-02 19:44:45 +12:00
COPY --from=builder /app/scripts/sync-homepage-content.mjs ./scripts/sync-homepage-content.mjs
COPY --from=builder /app/deploy-data/homepage-content.json ./deploy-data/homepage-content.json
2026-05-02 08:26:18 +12:00
EXPOSE 3000
CMD ["node", "build"]