-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile
38 lines (29 loc) · 856 Bytes
/
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
# Use node:20-alpine as the base image
FROM node:20-alpine AS base
# Set the working directory
WORKDIR /app
# Install dependencies
FROM base AS deps
COPY package.json ./
RUN npm install
# Build the application
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Prepare the runner stage
FROM node:20-alpine AS runner
# Set the working directory
WORKDIR /app
# Copy the necessary files from the builder stage
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.next/server ./.next/server
# Expose the application port
EXPOSE 3000
# Set environment variables
ENV HOSTNAME=:: PORT=3000
# Start the application
CMD ["node", "server.js"]