-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (32 loc) · 1.02 KB
/
Dockerfile
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
# Use the official Node.js 18.16.0 Alpine image as the base image
FROM node:18.16.0-alpine AS base
# Install Next.js globally
RUN yarn global add next
# Set the working directory to /app
WORKDIR /app
# Install dependencies
COPY package.json yarn.lock ./
RUN yarn install --production
# Copy the entire project to the working directory
COPY . .
# Build the Next.js project
RUN npm run build
# Stage 2: Create a lightweight production image
FROM node:18.16.0-alpine AS production
# Set the working directory to /app
WORKDIR /app
# Install dependencies
COPY package.json yarn.lock ./
RUN yarn install --production
# Copy the built files from the previous stage
COPY --from=base /app/.next ./.next
COPY --from=base /app/server.js ./
COPY --from=base /app/pages ./pages
COPY --from=base /app/components ./components
COPY --from=base /app/api ./api
COPY --from=base /app/styles ./styles
COPY --from=base /app/public ./public
# Expose the desired port
EXPOSE 8080
# Set the command to start the Next.js application
CMD ["node", "server.js"]