-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (37 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
50 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
##################################
# Stage 1: Build Stage
##################################
FROM node:18-alpine AS builder
# Add metadata for authorship and app identification
LABEL maintainer="Amitabh Soni <amitabhdevops2024@gmail.com>" \
app="gemini" \
stage="build"
WORKDIR /app
# Install build dependencies
COPY package.json package-lock.json* ./
RUN npm ci
# Copy source and build
COPY . .
RUN npm run build
# Clean up dev dependencies after build
RUN rm -rf node_modules && npm cache clean --force
##################################
# Stage 2: Production Stage
##################################
FROM node:18-alpine AS production
# Add metadata for the final image
LABEL maintainer="Amitabh Soni <amitabhdevops2024@gmail.com>" \
app="gemini" \
stage="production"
WORKDIR /app
# Install only production dependencies
COPY package.json package-lock.json* ./
RUN npm ci --production && npm cache clean --force
# Copy minimal required files
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.mjs ./
# Set production environment
ENV NODE_ENV=production
EXPOSE 3000
CMD ["npm", "start"]