-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Dockerfile
52 lines (38 loc) · 1.07 KB
/
Dockerfile
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
51
52
FROM node:22-alpine AS base
# Stage 1: Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json yarn.lock ./
# postinstall script requires a public directory
RUN mkdir -p /app/public && \
yarn install --frozen-lockfile
# Stage 2: Build the application
FROM base AS builder
ENV NODE_ENV=production
ENV CI=true
ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
COPY --from=deps /app/public ./public
RUN yarn build
# Stage 3: Prepare the production image
FROM base AS runner
ENV GITHUB_TOKEN=
ENV PROJECT_URL=http://localhost:3000
ENV GTM_ID=
ENV PORT=3000
ENV NODE_ENV=production
ENV CI=true
ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /app
# Copy only the necessary files and install production dependencies
COPY package.json yarn.lock ./
RUN mkdir -p /app/public && \
yarn install --production --frozen-lockfile && \
yarn cache clean
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.js /app/custom-rewrites.js ./
EXPOSE 3000
CMD ["yarn", "start"]