-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (34 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
49 lines (34 loc) · 1.16 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
# Stage 1: Builder - Install dependencies and build the application
FROM node:20-alpine AS builder
# Set the application's working directory
WORKDIR /app
# Install pnpm globally
RUN npm install -g pnpm
# Copy dependency files
COPY package.json pnpm-lock.yaml ./
# Install only dependencies (to leverage Docker layer caching)
RUN pnpm fetch
RUN pnpm install --prod=false --ignore-scripts
# Copy application source code
COPY . .
# Install bash and grant execute permission to the script
RUN apk add --no-cache bash && \
chmod +x ./scripts/generate-i18n-declaration.sh
# Build the application
RUN pnpm build
# Stage 2: Runner - Create a small image with only the necessary files for production
FROM node:20-alpine AS runner
WORKDIR /app
# Install pnpm globally
RUN npm install -g pnpm
# Copy only the necessary files from the builder stage
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Install production dependencies
RUN pnpm install --prod
EXPOSE 3000
ENV PORT 3000
CMD ["pnpm", "start"]