Skip to content

Commit 7f25697

Browse files
authored
Fix supervisor builds (#1790)
* fix and restructure dockerignore * switch to using pnpm deploy * pass webapp node image as build arg * ensure pnpm is downloaded at build, not runtime
1 parent 3a04759 commit 7f25697

File tree

3 files changed

+49
-65
lines changed

3 files changed

+49
-65
lines changed

.dockerignore

+32-40
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,23 @@
1-
\*.log
2-
.git
3-
.github
4-
5-
# editor
6-
7-
.idea
8-
.vscode
9-
10-
# dependencies
11-
1+
**/*.log
2+
**/*.pem
3+
**/*.tsbuildinfo
4+
5+
**/.cache
6+
**/.env
7+
**/.next
8+
**/.output
9+
**/.trigger
10+
**/.tshy
11+
**/.tshy-build
12+
**/.turbo
13+
**/.vercel
14+
**/.wrangler
15+
16+
**/dist
1217
**/node_modules
13-
.pnp
14-
.pnp.js
15-
16-
# testing
17-
18-
coverage
19-
20-
# next.js
2118

22-
.next/
23-
build
24-
25-
# packages
26-
27-
build
28-
dist
29-
packages/\*\*/dist
30-
31-
# misc
32-
33-
.DS_Store
34-
\*.pem
35-
36-
.turbo
37-
.vercel
38-
.cache
39-
.output
40-
.trigger
41-
apps/\*\*/public/build
19+
apps/webapp/build
20+
apps/webapp/public/build
4221

4322
cypress/screenshots
4423
cypress/videos
@@ -47,8 +26,21 @@ apps/**/styles/tailwind.css
4726
packages/**/styles/tailwind.css
4827

4928
.changeset
50-
references
29+
.DS_Store
30+
.git
31+
.github
32+
.idea
33+
.pnp
34+
.pnp.js
35+
.vscode
36+
37+
coverage
38+
build
39+
docs
5140
examples
41+
out
42+
references
43+
5244
CHANGESETS.md
5345
CONTRIBUTING.md
5446
README.md

apps/supervisor/Containerfile

+12-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ FROM node-22-alpine AS pruner
66

77
COPY --chown=node:node . .
88
RUN npx -q [email protected] prune --scope=supervisor --docker
9-
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
109

1110
FROM node-22-alpine AS base
1211

@@ -17,26 +16,17 @@ COPY --from=pruner --chown=node:node /app/out/json/ .
1716
COPY --from=pruner --chown=node:node /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
1817
COPY --from=pruner --chown=node:node /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
1918

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
19+
RUN corepack enable && corepack prepare --activate
3020

31-
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --prod --no-frozen-lockfile
21+
FROM base AS deps-fetcher
22+
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile
3223

33-
COPY --from=pruner --chown=node:node /app/internal-packages/database/prisma/schema.prisma /app/internal-packages/database/prisma/schema.prisma
24+
FROM deps-fetcher AS dev-deps
25+
ENV NODE_ENV development
3426

35-
ENV NPM_CONFIG_IGNORE_WORKSPACE_ROOT_CHECK true
36-
RUN pnpx [email protected] generate --schema /app/internal-packages/database/prisma/schema.prisma
27+
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile --offline --ignore-scripts
3728

3829
FROM base AS builder
39-
RUN corepack enable
4030

4131
COPY --from=pruner --chown=node:node /app/out/full/ .
4232
COPY --from=dev-deps --chown=node:node /app/ .
@@ -45,19 +35,19 @@ COPY --chown=node:node .configs/tsconfig.base.json .configs/tsconfig.base.json
4535
COPY --chown=node:node scripts/updateVersion.ts scripts/updateVersion.ts
4636

4737
RUN pnpm run generate && \
48-
pnpm run -r --filter supervisor... build
38+
pnpm run --filter supervisor... build&& \
39+
pnpm deploy --filter=supervisor --prod /prod/supervisor
4940

5041
FROM base AS runner
5142

52-
RUN corepack enable
5343
ENV NODE_ENV production
5444

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
45+
COPY --from=builder /prod/supervisor /app/apps/supervisor
5846

5947
EXPOSE 8000
60-
6148
USER node
6249

50+
# ensure pnpm is installed during build and not silently downloaded at runtime
51+
RUN pnpm -v
52+
6353
CMD [ "/usr/bin/dumb-init", "--", "pnpm", "run", "--filter", "supervisor", "start"]

docker/Dockerfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe AS pruner
1+
ARG NODE_IMAGE=node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe
2+
3+
FROM ${NODE_IMAGE} AS pruner
24

35
WORKDIR /triggerdotdev
46

@@ -7,7 +9,7 @@ RUN npx -q [email protected] prune --scope=webapp --docker
79
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
810

911
# Base strategy to have layer caching
10-
FROM node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe AS base
12+
FROM ${NODE_IMAGE} AS base
1113
RUN apt-get update && apt-get install -y openssl dumb-init
1214
WORKDIR /triggerdotdev
1315
COPY --chown=node:node .gitignore .gitignore
@@ -53,7 +55,7 @@ RUN pnpm run generate
5355
RUN pnpm run build --filter=webapp...
5456

5557
# Runner
56-
FROM node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe AS runner
58+
FROM ${NODE_IMAGE} AS runner
5759
RUN apt-get update && apt-get install -y openssl netcat-openbsd ca-certificates
5860
WORKDIR /triggerdotdev
5961
RUN corepack enable

0 commit comments

Comments
 (0)