Skip to content

Fix supervisor builds #1790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 32 additions & 40 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
\*.log
.git
.github

# editor

.idea
.vscode

# dependencies

**/*.log
**/*.pem
**/*.tsbuildinfo

**/.cache
**/.env
**/.next
**/.output
**/.trigger
**/.tshy
**/.tshy-build
**/.turbo
**/.vercel
**/.wrangler

**/dist
**/node_modules
.pnp
.pnp.js

# testing

coverage

# next.js

.next/
build

# packages

build
dist
packages/\*\*/dist

# misc

.DS_Store
\*.pem

.turbo
.vercel
.cache
.output
.trigger
apps/\*\*/public/build
apps/webapp/build
apps/webapp/public/build

cypress/screenshots
cypress/videos
Expand All @@ -47,8 +26,21 @@ apps/**/styles/tailwind.css
packages/**/styles/tailwind.css

.changeset
references
.DS_Store
.git
.github
.idea
.pnp
.pnp.js
.vscode

coverage
build
docs
examples
out
references

CHANGESETS.md
CONTRIBUTING.md
README.md
Expand Down
34 changes: 12 additions & 22 deletions apps/supervisor/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ FROM node-22-alpine AS pruner

COPY --chown=node:node . .
RUN npx -q turbo@1.10.9 prune --scope=supervisor --docker
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

FROM node-22-alpine AS base

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

FROM base AS dev-deps
RUN corepack enable
ENV NODE_ENV development

RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --no-frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --ignore-scripts --no-frozen-lockfile

FROM base AS prod-deps
RUN corepack enable
ENV NODE_ENV production
RUN corepack enable && corepack prepare --activate

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

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

ENV NPM_CONFIG_IGNORE_WORKSPACE_ROOT_CHECK true
RUN pnpx prisma@5.4.1 generate --schema /app/internal-packages/database/prisma/schema.prisma
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile --offline --ignore-scripts

FROM base AS builder
RUN corepack enable

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

RUN pnpm run generate && \
pnpm run -r --filter supervisor... build
pnpm run --filter supervisor... build&& \
pnpm deploy --filter=supervisor --prod /prod/supervisor

FROM base AS runner

RUN corepack enable
ENV NODE_ENV production

COPY --from=pruner --chown=node:node /app/out/full/ .
COPY --from=prod-deps --chown=node:node /app .
COPY --from=builder --chown=node:node /app/apps/supervisor ./apps/supervisor
COPY --from=builder /prod/supervisor /app/apps/supervisor

EXPOSE 8000

USER node

# ensure pnpm is installed during build and not silently downloaded at runtime
RUN pnpm -v

CMD [ "/usr/bin/dumb-init", "--", "pnpm", "run", "--filter", "supervisor", "start"]
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe AS pruner
ARG NODE_IMAGE=node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe

FROM ${NODE_IMAGE} AS pruner

WORKDIR /triggerdotdev

Expand All @@ -7,7 +9,7 @@ RUN npx -q turbo@1.10.9 prune --scope=webapp --docker
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

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

# Runner
FROM node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe AS runner
FROM ${NODE_IMAGE} AS runner
RUN apt-get update && apt-get install -y openssl netcat-openbsd ca-certificates
WORKDIR /triggerdotdev
RUN corepack enable
Expand Down
Loading