-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (40 loc) · 1.22 KB
/
Dockerfile
File metadata and controls
57 lines (40 loc) · 1.22 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Multi-stage build for Raspberry Pi (arm64/armv7) and generic Linux
# Using Alpine to avoid CVE-2023-45853 (zlib vulnerability in Debian)
# Stage 1: Builder
FROM node:20-alpine AS builder
# Cache bust arg - change value to force full rebuild
ARG CACHE_BUST=1
# Install build deps (sharp needs libvips, build tools)
RUN apk add --no-cache \
python3 \
make \
g++ \
vips-dev \
git
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --legacy-peer-deps
COPY . .
# Build Next.js
RUN npm run build
# Stage 2: Runner
FROM node:20-alpine AS runner
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000
# Install runtime deps for sharp (vips)
RUN apk add --no-cache \
vips
WORKDIR /app
# Copy standalone output from builder
COPY --from=builder /app/.next/standalone ./
# Copy public directory (not included in standalone output)
COPY --from=builder /app/public ./public
# Copy static files (not included in standalone output)
COPY --from=builder /app/.next/static ./.next/static
# Copy config directory (for build-time config, volume mount overrides at runtime)
COPY --from=builder /app/config ./config
# Create images directory for volume mount
RUN mkdir -p ./images
EXPOSE 3000
CMD ["node", "server.js"]