-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (26 loc) · 856 Bytes
/
Dockerfile
File metadata and controls
32 lines (26 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Stage 1: Dependencies
FROM node:18-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Use BuildKit cache mount for npm cache to speed up builds
RUN --mount=type=cache,target=/root/.npm \
npm ci
# Stage 2: Builder
FROM node:18-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build static Next.js site
ENV NEXT_TELEMETRY_DISABLED 1
# Use BuildKit cache mount for Next.js build cache to speed up builds
RUN --mount=type=cache,target=/app/.next/cache \
npm run build
# Stage 3: Runner - Serve with Caddy (301-friendly redirects)
FROM caddy:2-alpine
# Copy built static site and Caddyfile
COPY --from=builder /app/out /srv/http
COPY Caddyfile /etc/caddy/Caddyfile
# Default Caddy port (matches Fly internal_port)
EXPOSE 8043