File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Stage 1: Build the application
2
+ FROM node:18 AS builder
3
+
4
+ # Set the working directory
5
+ WORKDIR /app
6
+
7
+ # Copy package.json and package-lock.json
8
+ COPY package.json package-lock.json* ./
9
+
10
+ # Install dependencies
11
+ RUN npm install --legacy-peer-deps
12
+ RUN npm ci
13
+ # Copy the rest of the application files
14
+ COPY . .
15
+
16
+ # Build the application
17
+ RUN npm run build
18
+
19
+ # Stage 2: Serve the application
20
+ FROM builder AS runner
21
+
22
+ # Set the working directory
23
+ WORKDIR /app
24
+ COPY --from=builder /app/public ./public
25
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
26
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
27
+
28
+ # Expose the application port
29
+ EXPOSE 3100
30
+
31
+ # Start the application on port 3100
32
+ ENV PORT=3100
33
+ CMD ["node" , "server.js" ]
Original file line number Diff line number Diff line change
1
+ version : ' 3.8'
2
+
3
+ services :
4
+ nextjs :
5
+ container_name : nextjs-app
6
+ build :
7
+ context : .
8
+ dockerfile : Dockerfile
9
+ ports :
10
+ - " 3100:3100"
11
+ environment :
12
+ - PORT=3100
13
+ volumes :
14
+ - .:/app # Mount the current directory to /app in the container
You can’t perform that action at this time.
0 commit comments