2024-09-28 18:17:37 -04:00
|
|
|
# Stage 1: Build the application
|
|
|
|
FROM node:18-alpine AS builder
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy package.json and package-lock.json
|
|
|
|
COPY package*.json ./
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
RUN npm ci
|
|
|
|
|
|
|
|
# Copy the rest of the application code
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
# Build the Next.js application and compile TypeScript
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
# Stage 2: Run the application
|
|
|
|
FROM node:18-alpine AS runner
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy package.json and package-lock.json
|
|
|
|
COPY package*.json ./
|
|
|
|
|
|
|
|
# Install only production dependencies
|
|
|
|
RUN npm ci --only=production
|
|
|
|
|
|
|
|
# Copy built application from the builder stage
|
|
|
|
COPY --from=builder /app/.next ./.next
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
|
|
|
|
# Start the application
|
2024-09-29 14:37:26 -04:00
|
|
|
CMD ["npm", "start"]
|