-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (41 loc) · 1.37 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
FROM node:20.17.0-alpine3.20 AS base
ARG NEXT_TELEMETRY_DISABLED=1
# Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
COPY prisma prisma
RUN corepack enable pnpm && pnpm i --frozen-lockfile
# Development image - will get the actual project files from bind mount
FROM base AS dev
WORKDIR /app
ARG NEXT_TELEMETRY_DISABLED
ENV NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED}
COPY --from=deps /app/package.json /app/pnpm-lock.yaml ./
COPY --from=deps --chown=node:node /app/node_modules ./node_modules
RUN corepack enable pnpm && mkdir .next && chown -R node:node .next
USER node
EXPOSE 3000
ENV PORT=3000
CMD [ "pnpm", "dev" ]
# Build the source code for production
FROM base AS builder
WORKDIR /app
ARG NEXT_TELEMETRY_DISABLED
ENV NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED}
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable pnpm && pnpm run build;
# Production image - copy just the build files and run next
FROM base AS prod
WORKDIR /app
ARG NEXT_TELEMETRY_DISABLED
ENV NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED}
ENV NODE_ENV=production
RUN mkdir .next && chown -R node:node .next
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
USER node
EXPOSE 3000
ENV PORT=3000
CMD ["sh", "-c", "HOSTNAME='0.0.0.0' node server.js"]