-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
39 lines (26 loc) · 1.02 KB
/
Dockerfile.frontend
File metadata and controls
39 lines (26 loc) · 1.02 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
# Stage 1: Dependencies Installation & Build
FROM node:20-alpine AS builder
WORKDIR /app/frontend
# Copy package.json and package-lock.json
COPY frontend/package.json frontend/package-lock.json ./
# Install dependencies using npm
RUN npm ci --legacy-peer-deps
# Copy the rest of your frontend application code
COPY frontend/. .
# Build the Next.js application using npm
RUN npm run build
# Stage 2: Production Server
FROM node:20-alpine AS runner
ENV NODE_ENV production
WORKDIR /app/frontend
# Copy package.json and package-lock.json (if it exists)
COPY --from=builder /app/frontend/package.json ./package.json
COPY --from=builder /app/frontend/package-lock.json ./package-lock.json
# Install only production dependencies
RUN npm ci --omit=dev --legacy-peer-deps && npm cache clean --force
# Copy the build artifacts from the builder stage
COPY --from=builder /app/frontend/.next ./.next
COPY --from=builder /app/frontend/public ./public
EXPOSE 3000
# Command to run the Next.js application using npm
CMD ["npm", "run", "start"]