mirror of
https://github.com/khoaliber/LetterFeed.git
synced 2026-03-02 13:18:27 +00:00
38 lines
794 B
Docker
38 lines
794 B
Docker
# Dockerfile for Next.js frontend
|
|
|
|
# 1. Build Stage
|
|
FROM node:24-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Copy package.json and package-lock.json
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Copy the rest of the application
|
|
COPY . .
|
|
|
|
# Set the API URL for the build
|
|
ARG NEXT_PUBLIC_API_URL=/api
|
|
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
|
|
|
# Build the Next.js application
|
|
RUN npm run build
|
|
|
|
# 2. Production Stage
|
|
FROM node:24-alpine
|
|
WORKDIR /app
|
|
|
|
# Copy the built application from the builder stage
|
|
COPY --from=builder /app/.next ./.next
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/package.json ./package.json
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["npm", "start"]
|