Skip to content

Commit 81e332f

Browse files
committed
add docker-image
1 parent 970a316 commit 81e332f

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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"]

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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

0 commit comments

Comments
 (0)