1
0
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity Security Code Quality
Files
cosmos-prototype-application/Dockerfile
2025-07-10 10:47:51 +07:00

41 lines
812 B
Docker

# Base image
FROM node:22-alpine AS builder
ARG NODE_ENV=production
ARG MONGODB_URI
ARG MONGODB_DB
# Create app directory
WORKDIR /app
# Install dependencies
COPY package.json ./
RUN apk add --no-cache libc6-compat
RUN rm -rf node_modules package-lock.json yarn.lock pnpm-lock.yaml
RUN npm install --omit=dev
# Copy the rest of the application
COPY . .
# Build the app
RUN npm run build
# Production image
FROM node:22-alpine AS runner
WORKDIR /app
# Copy only necessary files
COPY --from=builder /app/package.json ./
COPY --from=builder /app/.next .next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/next.config.ts ./
# Set environment variables (optional)
# Expose port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]