-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
70 lines (50 loc) · 2.47 KB
/
Dockerfile.frontend
File metadata and controls
70 lines (50 loc) · 2.47 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
58
59
60
61
62
63
64
65
66
67
68
69
70
# ──────────────────────────────────────────────────────────────────────
# Dockerfile.frontend — SEC Semantic Search React UI
#
# Multi-stage build:
# 1. deps — install node_modules (cached layer)
# 2. builder — build Next.js standalone output
# 3. runner — minimal Node.js runtime
#
# The standalone output bundles only the necessary node_modules and
# produces a self-contained server.js — no npm install at runtime.
# ──────────────────────────────────────────────────────────────────────
# ── Stage 1: Dependencies ────────────────────────────────────────────
FROM node:22.22.1-alpine AS deps
WORKDIR /app
# Install dependencies (cached unless package files change)
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci --ignore-scripts
# ── Stage 2: Builder ─────────────────────────────────────────────────
FROM node:22.22.1-alpine AS builder
WORKDIR /app
# Copy installed node_modules from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy frontend source
COPY frontend/ ./
# Build the Next.js application (standalone output)
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# ── Stage 3: Runner ──────────────────────────────────────────────────
FROM node:22.22.1-alpine AS runner
WORKDIR /app
# Create non-root user
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
# Copy the standalone build output
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# Set ownership
RUN chown -R nextjs:nodejs /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
HOSTNAME=0.0.0.0 \
PORT=3000
USER nextjs
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/ || exit 1
# Start the standalone Next.js server
CMD ["node", "server.js"]