Skip to content

Commit d4100f9

Browse files
committed
add supervisor containerfile
1 parent e1eb2e4 commit d4100f9

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

apps/supervisor/Containerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM node:22-alpine@sha256:9bef0ef1e268f60627da9ba7d7605e8831d5b56ad07487d24d1aa386336d1944 AS node-22-alpine
2+
3+
WORKDIR /app
4+
5+
FROM node-22-alpine AS pruner
6+
7+
COPY --chown=node:node . .
8+
RUN npx -q [email protected] prune --scope=supervisor --docker
9+
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
10+
11+
FROM node-22-alpine AS base
12+
13+
RUN apk add --no-cache dumb-init
14+
15+
COPY --chown=node:node .gitignore .gitignore
16+
COPY --from=pruner --chown=node:node /app/out/json/ .
17+
COPY --from=pruner --chown=node:node /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
18+
COPY --from=pruner --chown=node:node /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
19+
20+
FROM base AS dev-deps
21+
RUN corepack enable
22+
ENV NODE_ENV development
23+
24+
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --no-frozen-lockfile
25+
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --ignore-scripts --no-frozen-lockfile
26+
27+
FROM base AS prod-deps
28+
RUN corepack enable
29+
ENV NODE_ENV production
30+
31+
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --prod --no-frozen-lockfile
32+
33+
COPY --from=pruner --chown=node:node /app/internal-packages/database/prisma/schema.prisma /app/internal-packages/database/prisma/schema.prisma
34+
35+
ENV NPM_CONFIG_IGNORE_WORKSPACE_ROOT_CHECK true
36+
RUN pnpx [email protected] generate --schema /app/internal-packages/database/prisma/schema.prisma
37+
38+
FROM base AS builder
39+
RUN corepack enable
40+
41+
COPY --from=pruner --chown=node:node /app/out/full/ .
42+
COPY --from=dev-deps --chown=node:node /app/ .
43+
COPY --chown=node:node turbo.json turbo.json
44+
COPY --chown=node:node .configs/tsconfig.base.json .configs/tsconfig.base.json
45+
COPY --chown=node:node scripts/updateVersion.ts scripts/updateVersion.ts
46+
47+
RUN pnpm run generate && \
48+
pnpm run -r --filter supervisor... build
49+
50+
FROM base AS runner
51+
52+
RUN corepack enable
53+
ENV NODE_ENV production
54+
55+
COPY --from=pruner --chown=node:node /app/out/full/ .
56+
COPY --from=prod-deps --chown=node:node /app .
57+
COPY --from=builder --chown=node:node /app/apps/supervisor ./apps/supervisor
58+
59+
EXPOSE 8000
60+
61+
USER node
62+
63+
CMD [ "/usr/bin/dumb-init", "--", "pnpm", "run", "--filter", "supervisor", "start"]

apps/supervisor/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "dist/index.js",
66
"type": "module",
77
"scripts": {
8+
"build": "tsc",
89
"dev": "tsx --experimental-sqlite --require dotenv/config --watch src/index.ts",
910
"start": "node --experimental-sqlite dist/index.js",
1011
"typecheck": "tsc --noEmit"

0 commit comments

Comments
 (0)