mirror of https://github.com/buster-so/buster.git
51 lines
961 B
Docker
51 lines
961 B
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Copy environment variables for build
|
|
COPY .env ./
|
|
COPY next.config.mjs ./
|
|
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the Next.js application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Set to production environment
|
|
ENV NODE_ENV=production
|
|
|
|
# Copy necessary files from builder
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next ./.next
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/package.json ./package.json
|
|
COPY --from=builder /app/next.config.mjs ./
|
|
# Copy environment files
|
|
COPY --from=builder /app/.env ./
|
|
|
|
# Expose the port your app runs on
|
|
EXPOSE 3000
|
|
|
|
# Add tini for proper signal handling
|
|
RUN apk add --no-cache tini
|
|
|
|
# Use tini as entrypoint
|
|
ENTRYPOINT ["/sbin/tini", "--"]
|
|
|
|
# Start the application
|
|
CMD ["npm", "start"]
|