-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Dockerfile
77 lines (55 loc) · 2.05 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable pnpm
FROM base AS base-deps
WORKDIR /home/node/repo
COPY ./package.json ./pnpm-*.yaml ./
COPY ./lib/package.json ./lib/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# Express
FROM base AS express-deps
WORKDIR /home/node/repo
COPY --from=base-deps /home/node/repo ./
COPY ./examples/express/package.json ./examples/express/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
FROM base AS express-build
WORKDIR /home/node/repo
COPY --from=express-deps /home/node/repo ./
COPY . /home/node/repo
RUN pnpm --filter !esi-next run build
RUN pnpm deploy --filter esi-express --prod /home/node/esi-express
FROM base AS express-prod
COPY --from=express-build /home/node/esi-express /home/node/esi-express
WORKDIR /home/node/esi-express
USER node
EXPOSE 3000
CMD [ "node", "dist/server.js" ]
# Nextjs
FROM base AS next-deps
WORKDIR /home/node/repo
COPY --from=base-deps /home/node/repo ./
COPY ./examples/next/package.json ./examples/next/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
FROM base AS next-build
WORKDIR /home/node/repo
COPY --from=next-deps /home/node/repo ./
COPY . /home/node/repo
ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm --filter !esi-express run build
RUN pnpm deploy --filter esi-next --prod /home/node/esi-next
FROM base AS next-prod
WORKDIR /home/node/esi-next
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown node:node .next
COPY --from=next-build --chown=node:node /home/node/esi-next/public ./public
COPY --from=next-build --chown=node:node /home/node/esi-next/node_modules ./node_modules
COPY --from=next-build --chown=node:node /home/node/esi-next/.next/standalone ./
COPY --from=next-build --chown=node:node /home/node/esi-next/dist ./dist
COPY --from=next-build --chown=node:node /home/node/esi-next/.next/static ./.next/static
USER node
EXPOSE 3000
CMD [ "node", "dist/server.js" ]