-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
80 lines (48 loc) · 1.91 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
78
79
80
ARG NODE_VERSION=22-slim
FROM node:${NODE_VERSION} AS dependencies
ENV PNPM_HOME="/var/cache/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /monorepo
RUN --mount=type=cache,id=pnpm-store,target=/var/cache/pnpm/store \
--mount=type=bind,source=package.json,target=/monorepo/package.json \
--mount=type=bind,source=pnpm-lock.yaml,target=/monorepo/pnpm-lock.yaml \
--mount=type=bind,source=pnpm-workspace.yaml,target=/monorepo/pnpm-workspace.yaml \
corepack enable && \
pnpm install --frozen-lockfile --strict-peer-dependencies
FROM dependencies AS pruner
ARG PROJECT
WORKDIR /monorepo
COPY . .
RUN pnpm exec turbo prune --docker ${PROJECT}
FROM dependencies AS builder
ARG PROJECT
ARG TURBO_TEAM
ARG TURBO_TOKEN
ENV TURBO_TEAM=${TURBO_TEAM}
ENV TURBO_TOKEN=${TURBO_TOKEN}
WORKDIR /app
COPY --from=pruner /monorepo/out/*.yaml ./
COPY --from=pruner /monorepo/out/json/ .
COPY --from=pruner /monorepo/tsconfig.base.json .
RUN --mount=type=cache,id=pnpm-store,target=/var/cache/pnpm/store \
pnpm install --frozen-lockfile --strict-peer-dependencies
COPY --from=pruner /monorepo/out/full/ .
RUN --mount=type=cache,id=pnpm-store,target=/var/cache/pnpm/store \
pnpm exec turbo run build --filter=${PROJECT} && \
pnpm --filter ${PROJECT} --prod deploy out/ && \
find -type f -name '*.ts' -exec rm -f '{}' \;
FROM gcr.io/distroless/nodejs22-debian12:nonroot AS backend
ARG PROJECT
ARG PORT=3030
ENV NODE_ENV=production
ENV PORT=${PORT}
COPY --from=builder --chown=nonroot:nonroot /app/out/dist ${PROJECT}
COPY --from=builder --chown=nonroot:nonroot /app/out/package.json ${PROJECT}/
COPY --from=builder --chown=nonroot:nonroot /app/out/node_modules ${PROJECT}/node_modules
WORKDIR /home/nonroot/${PROJECT}
EXPOSE ${PORT}
HEALTHCHECK CMD ["/nodejs/bin/node", "health-check.js"]
CMD ["index.js"]
FROM devforth/spa-to-http:latest AS frontend
ARG PROJECT
COPY --from=builder /app/apps/${PROJECT}/dist/ .