-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (44 loc) · 1.33 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (44 loc) · 1.33 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
# syntax=docker/dockerfile:1.5
# Install dependencies in a separate layer for better caching
FROM node:20-alpine AS deps
WORKDIR /app
# Copy only manifest and lockfile to maximize cache hits
COPY package.json package-lock.json* ./
# Install dependencies with npm
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
# Build the Next.js app
FROM node:20-alpine AS builder
WORKDIR /app
# Reuse node_modules from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy the full source
COPY . .
# Sentry release/source map upload args (set by CI at build time)
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_ORG
ARG SENTRY_PROJECT
ARG SENTRY_RELEASE
ARG NEXT_PUBLIC_SENTRY_DSN
ARG SENTRY_DSN
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_ORG=$SENTRY_ORG
ENV SENTRY_PROJECT=$SENTRY_PROJECT
ENV SENTRY_RELEASE=$SENTRY_RELEASE
ENV NEXT_PUBLIC_SENTRY_DSN=$NEXT_PUBLIC_SENTRY_DSN
ENV SENTRY_DSN=$SENTRY_DSN
# Build for production
RUN npm run build
# Runtime image
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
# Copy only the production artifacts
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
# Expose the Next.js port
EXPOSE 3000
# Start the server
CMD ["npm", "run", "start"]