-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
50 lines (37 loc) · 1.2 KB
/
Dockerfile.frontend
File metadata and controls
50 lines (37 loc) · 1.2 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
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml* package-lock.json* ./
# Install dependencies (prefer pnpm if lock file exists)
RUN if [ -f pnpm-lock.yaml ]; then \
corepack enable && corepack prepare pnpm@latest --activate && pnpm install --frozen-lockfile; \
elif [ -f package-lock.json ]; then \
npm ci; \
else \
npm install; \
fi
# Copy source code
COPY . .
# Set environment variables for build
# API paths already include /api prefix in code, so baseURL should be empty
ENV NEXT_PUBLIC_API_URL=
ENV NODE_ENV=production
# Build Next.js application (standalone output)
RUN npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Set environment to production
ENV NODE_ENV=production
# Copy standalone output from builder
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
# Start application
CMD ["node", "server.js"]