-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Use an official Node.js runtime as the base image | ||
FROM node:18-alpine AS builder | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install dependencies | ||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
|
||
# Copy the rest of the application code | ||
COPY . . | ||
|
||
# Build the Next.js application | ||
RUN npm run build | ||
|
||
# Production image | ||
FROM node:18-alpine AS runner | ||
|
||
# Set NODE_ENV to production | ||
ENV NODE_ENV=production | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install production dependencies | ||
COPY package.json package-lock.json ./ | ||
RUN npm ci --only=production | ||
|
||
# Copy the built application from the builder stage | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/next.config.js ./ | ||
COPY --from=builder /app/package.json ./ | ||
COPY --from=builder /app/node_modules ./node_modules | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3000 | ||
|
||
# Start the Next.js application | ||
CMD ["npm", "start"] |