Skip to content

Skip the duplicate type check inside the webapp Docker build #560

Closed

Description

@HMarzban

Part of #554. Change set B. Rulings: #554 rulings 1, 5, 6, 13, 15, 16.

Summary

  • Today. Every deploy type-checks the webapp three times:
    1. the 📝 Type Check job (tsc --noEmit);
    2. 🏗️ Build Verification, whose next build runs Next's own type check;
    3. next build again, inside the webapp image build on the prod host.
  • The third check is on the critical path, inside 🏗️ Build Docker Images. It took 25.2–48.1 s, median 31.2 s, in six recent deploys: the Creating an optimized production build offset minus the Checking validity of types offset.
Run Deploy job Type check start (s) Compile start (s) Type check (s)
38068638114 114262648443 3.428 35.70 32.3
38239392350 114780192678 3.286 31.58 28.3
38392614215 115281929767 2.844 46.00 43.2
39275929831 118142985559 3.100 28.34 25.2
39297468969 118217497479 3.623 33.75 30.1
39398067267 118549257854 3.195 51.32 48.1

Depends on / Blocks

Current behaviour

All links are pinned to d0a53756f8676556358b6adc6c2397d2ed7c64c8.

  1. The only typescript block in next.config.js never applies (next.config.js:77-94):

      ...(process.env.NODE_ENV === 'development' && {
        // Skip type checking during dev (Next.js handles it separately)
        typescript: {
          ignoreBuildErrors: false // Still check, but don't block compilation
        },

    Lines 79–82 set Next's default, against their own comment. next dev runs no build type check, and the builder stage sets NODE_ENV=production (Dockerfile.bun:132, :155). So the block changes nothing.

  2. There is no top-level typescript key. The nearest one is eslint: { ignoreDuringBuilds: true } (next.config.js:195-197).

  3. The installed Next is 15.5.27 (apps/webapp/package.json:81). In next/dist/build/type-check.js, startTypeChecking reads config.typescript.ignoreBuildErrors. When it is true, Next logs Skipping validation of types and does not start the check.

  4. The builder stage order (Dockerfile.bun:123-219):
    line 191 RUN bun install --frozen-lockfile; line 198 COPY apps/webapp ./apps/webapp; lines 200–210 GIT_HASH and NEXT_PUBLIC_GIT_HASH, below the install (AGENTS.md:295); line 219 RUN --mount=type=cache,target=/app/apps/webapp/.next/cache bunx next build, which never caches.

  5. The deploy builds the webapp in one compose call with no build argument (prod.docs.plus.yml:612-642):

              docker compose -f "${COMPOSE_FILE}" --env-file "${ENV_FILE}" \
                build webapp admin-dashboard
  6. The compose file has no NEXT_SKIP_TYPECHECK (docker-compose.prod.yml:493-518). Stage (stage.docs.plus.yml:48) and apps/webapp/Makefile (Makefile:32) also read this file.

  7. Two gates already type-check every deploy commit:

  8. 🚀 Deploy Production needs needs.build.result == 'success' (prod.docs.plus.yml:427-435).

  9. skip_quality_gates does not skip Build Verification. The input is at prod.docs.plus.yml:41-45. The build job's if only accepts failed gates under it (:366-376).

  10. The admin type check is off the critical path. In job 118217497479 it printed Finished TypeScript in 18.3s, and its next build ended at 18:00:57 UTC. The webapp next build started at 18:03:02 UTC and ran 185.4 s.

Target behaviour

  • Prod push deploy and force_deploy dispatch: the webapp next build prints Skipping validation of types.
  • skip_quality_gates dispatch: the Docker build passes NEXT_SKIP_TYPECHECK=0 and still type-checks.
  • No change for Build Verification, stage, the Makefile, dev compose, self-hosters and the admin image.
  • Install cache: changing only NEXT_SKIP_TYPECHECK leaves the builder install CACHED.

Implementation steps

Read every file in Read first before Step 0.

Step 0. Read and check the base

  1. Confirm each cited line still matches on main:

    git show main:apps/webapp/next.config.js | sed -n '77,94p;195,197p'
    git show main:apps/webapp/docker/Dockerfile.bun | sed -n '123,132p;190,219p'
    git show main:.github/workflows/prod.docs.plus.yml | grep -n -A30 'name: 🏗️ Build Docker Images'
    git show main:docker-compose.prod.yml | grep -n -A28 '^  webapp:'
  2. Expect the quotes in Current behaviour. If Build the deploy images while the quality gates run #565 has landed, the build step lives in the images job instead of deploy. Make the Step 3 change there.

  3. If the dev-only typescript block is gone, or a top-level typescript key exists, stop. Re-derive Step 1 from the new file, and comment here with what changed.

  4. Confirm Next is still 15.x:

    grep -n '"next"' apps/webapp/package.json
    grep -n "Skipping validation of types" apps/webapp/node_modules/next/dist/build/type-check.js

    If Next is 16 or later, or the second command prints nothing, stop. Read the new type-check code first, and comment here.

  5. Confirm the rollback guard is on main:

    git show main:.github/workflows/prod.docs.plus.yml | grep -n -A2 'name: 🚨 Rollback on Failure'

    Expect an if: of the form failure() && env.<marker> == 'true'. If it is still a bare if: failure(), stop and comment here.

Step 1. apps/webapp/next.config.js

  1. Delete lines 79–82, the comment and the typescript block inside the NODE_ENV === 'development' spread. Keep every other key in that spread.

  2. Add a top-level key just before eslint: { (line 195 today):

      // The prod deploy sets NEXT_SKIP_TYPECHECK=1 on the Docker build only. The
      // `typecheck` job and Build Verification already type-check that commit.
      typescript: {
        ignoreBuildErrors: process.env.NEXT_SKIP_TYPECHECK === '1'
      },
  3. Check it with node. Next loads this file under Node, and Bun fails to require it in a -e script.

    cd apps/webapp
    NODE_ENV=production node -e "console.log(JSON.stringify(require('./next.config.js').typescript))" 2>/dev/null | tail -1
    NODE_ENV=production NEXT_SKIP_TYPECHECK=1 node -e "console.log(JSON.stringify(require('./next.config.js').typescript))" 2>/dev/null | tail -1
    NODE_ENV=production NEXT_SKIP_TYPECHECK=0 node -e "console.log(JSON.stringify(require('./next.config.js').typescript))" 2>/dev/null | tail -1

    Expect {"ignoreBuildErrors":false}, then {"ignoreBuildErrors":true}, then {"ignoreBuildErrors":false}.

Step 2. apps/webapp/docker/Dockerfile.bun

  1. Add this block after line 210, the end of the GIT_HASH ENV. It must sit below line 198, so the line 191 install keeps its cache key.

    # Below the install for the same cache reason as GIT_HASH. Only the prod deploy
    # sets 1; empty (stage, Makefile, dev, self-hosters) keeps Next's type check.
    ARG NEXT_SKIP_TYPECHECK
    ENV NEXT_SKIP_TYPECHECK=${NEXT_SKIP_TYPECHECK}
  2. Do not move or edit any other line. Do not add the argument to the deps, build-extensions or runner stages.

  3. Check placement:

    grep -n 'RUN bun install --frozen-lockfile\|^COPY apps/webapp\|NEXT_SKIP_TYPECHECK\|bunx next build' apps/webapp/docker/Dockerfile.bun

    Expect lines in this order:

    • COPY apps/webapp/package.json ./apps/webapp/ in deps (59 today);
    • the build-extensions install (107 today);
    • the builder install (191 today);
    • COPY apps/webapp ./apps/webapp (198 today);
    • the ARG NEXT_SKIP_TYPECHECK and ENV NEXT_SKIP_TYPECHECK lines;
    • bunx next build (219 before the change).

    Both NEXT_SKIP_TYPECHECK lines must sit between COPY apps/webapp ./apps/webapp and bunx next build.

Step 3. .github/workflows/prod.docs.plus.yml, step 🏗️ Build Docker Images

  1. Add one env entry to the step's env: map. Find it by the step name; it was lines 613–615 at the pin. On push it is false. On a dispatch it is the boolean input.

            env:
              DOCKER_BUILDKIT: '1'
              COMPOSE_DOCKER_CLI_BUILD: '1'
              SKIP_QUALITY_GATES: ${{ github.event_name == 'workflow_dispatch' && inputs.skip_quality_gates }}
  2. Replace the webapp call, the docker compose … build webapp admin-dashboard lines and the 3-line comment above them (636–640 at the pin), with:

              # No --parallel: it is not a `docker compose build` flag in Compose v2
              # (absent from `docker compose build --help`). Named services already
              # build concurrently.
              # Typecheck and Build Verification already ran tsc on this commit. An
              # emergency dispatch (skip_quality_gates) keeps the check in the image.
              NEXT_SKIP_TYPECHECK=1
              if [ "${SKIP_QUALITY_GATES}" = "true" ]; then NEXT_SKIP_TYPECHECK=0; fi
              docker compose -f "${COMPOSE_FILE}" --env-file "${ENV_FILE}" \
                build --build-arg "NEXT_SKIP_TYPECHECK=${NEXT_SKIP_TYPECHECK}" webapp admin-dashboard

    --build-arg applies to both services; the admin build ignores it. Do not split the call into two. Do not touch the backend --no-cache call (633–634 at the pin).

  3. Check the branch logic with no runner:

    for v in true false ''; do SKIP_QUALITY_GATES="$v" bash -c 'NEXT_SKIP_TYPECHECK=1; if [ "${SKIP_QUALITY_GATES}" = "true" ]; then NEXT_SKIP_TYPECHECK=0; fi; echo "[$SKIP_QUALITY_GATES] -> $NEXT_SKIP_TYPECHECK"'; done

    Expect [true] -> 0, [false] -> 1 and [] -> 1.

  4. Run actionlint (see Verification). Expect no new finding.

Step 4. Binary cache-hit check

Run this on a dev machine with Docker, never on the prod host. It checks cache hits and log lines only, so the architecture does not matter.

  1. Stop any running next dev for apps/webapp first.

  2. From the repo root, build the builder stage twice with the cache on. Change only NEXT_SKIP_TYPECHECK:

    ARGS="--build-arg NEXT_PUBLIC_RESTAPI_URL=http://localhost:4000/api \
      --build-arg NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321 \
      --build-arg NEXT_PUBLIC_SUPABASE_ANON_KEY=dummy-key"
    docker build -f apps/webapp/docker/Dockerfile.bun --target builder --progress=plain \
      $ARGS -t docsplus-webapp-tc:unset . 2>&1 | tee /tmp/tc-unset.log
    docker build -f apps/webapp/docker/Dockerfile.bun --target builder --progress=plain \
      $ARGS --build-arg NEXT_SKIP_TYPECHECK=1 -t docsplus-webapp-tc:skip . 2>&1 | tee /tmp/tc-skip.log
  3. Check the results:

    grep -c 'Checking validity of types' /tmp/tc-unset.log    # expect 1
    grep -c 'Skipping validation of types' /tmp/tc-skip.log   # expect 1
    grep -c 'Checking validity of types' /tmp/tc-skip.log     # expect 0
    grep -A1 '\[builder .*RUN bun install --frozen-lockfile' /tmp/tc-skip.log | grep -c CACHED   # expect 1
  4. If the last command prints 0, the argument moved the install cache key. Stop and fix the placement in Step 2.

  5. Remove the two local images: docker rmi docsplus-webapp-tc:unset docsplus-webapp-tc:skip.

  6. Post the four grep results as a comment here.

Review checkpoint

  1. Show the change set:

    git status --short
    git diff -- apps/webapp/next.config.js apps/webapp/docker/Dockerfile.bun .github/workflows/prod.docs.plus.yml
  2. Expect changes in those three files only.

  3. Do not commit inside these steps. After the maintainer reviews the diff, commit and push per SP2 ([Tracking] Faster, change-aware CI/CD pipeline #554). Land after Roll back only after the deploy has started rolling services #555.

Acceptance criteria

  • next.config.js has one top-level typescript key, ignoreBuildErrors: process.env.NEXT_SKIP_TYPECHECK === '1'. The dev-only typescript block is gone, and the other dev-only keys remain.
  • The Step 1 node checks print false, true and false.
  • Dockerfile.bun declares ARG NEXT_SKIP_TYPECHECK and its ENV in the builder stage, below COPY apps/webapp ./apps/webapp and above bunx next build.
  • The Step 4 cache-hit check prints 1, 1, 0 and 1, posted as a comment here.
  • The webapp compose call passes --build-arg "NEXT_SKIP_TYPECHECK=${NEXT_SKIP_TYPECHECK}", which is 1 unless skip_quality_gates is true. docker-compose.prod.yml is unchanged.
  • actionlint reports no new finding on .github/workflows/prod.docs.plus.yml.
  • The 🏗️ Build Verification log of the first CI run that carries this change still prints Checking validity of types. That run is the PR run if a PR exists, otherwise the first push run on main.
  • On the first (build): deploy with this change, the webapp next build prints Skipping validation of types, not Checking validity of types.
  • On that deploy, Creating an optimized production build prints at an offset of 6 s or less. The baseline median is 34.7 s.
  • On that deploy, the admin build still prints Finished TypeScript.
  • On that deploy, 🩺 Verify Deployment passes and the webapp containers are healthy.
  • A "Measured, " comment is posted here (see Accountability).

Verification

Before the change reaches main:

actionlint -config-file .github/actionlint.yaml .github/workflows/prod.docs.plus.yml
  • No parse-build-trigger.test.sh run and no dry_run_subject dispatch: triage and job ifs do not change.
  • Do not run a real skip_quality_gates or force_deploy dispatch. That deploys production. Step 3.3 checks the branch logic.

After the change reaches main, on the first (build): push deploy that carries it:

  1. Find the job that holds 🏗️ Build Docker Images: 🚀 Deploy Production today, the images job after Build the deploy images while the quality gates run #565.

    gh run view <run_id> --repo docs-plus/docs.plus --json createdAt,jobs \
      -q '.jobs[] | select(.steps[]?.name | test("Build Docker Images")) | .databaseId'
  2. Read the webapp type-check lines from that job:

    gh run view --job <job_id> --repo docs-plus/docs.plus --log \
      | grep -E 'webapp builder .*bunx next build|validity of types|Skipping validation of types|Creating an optimized production build|Finished TypeScript'

    The webapp next build lines share one BuildKit step number, for example #109. Read the offsets after that number.

  3. Record per SP3 ([Tracking] Faster, change-aware CI/CD pipeline #554). Metrics are defined in Measure CI/CD time to live after the v2.3 work: 1090 s median before #569. This issue's rows:

Metric Run to read Baseline Expected
Type-check phase (Creating an optimized production build offset) the job from item 1 median 34.7 s (range 28.34–51.32 s, six jobs above) 6 s or less
M3 same run median 546 s, range 316–866 s (14 deploys, 2026-09-22 to 2026-10-20) about 31 s lower than a deploy of the same cache class; not judged from one deploy
M1 same run median 1090 s, p90 1386 s about 31 s lower, inside normal noise; final result in #569
M2g, M2i, M4, M5, W, M6 same run as in #569 no change from this issue

#559 and other set B items also change M3 and M1. This issue owns only the type-check phase.

Accountability

  • Who checks. The builder, or the maintainer if the builder cannot.
  • What. Verification items 1–3 and the last four acceptance criteria, on the first (build): deploy with this change.
  • Where. The SP3 comment here, plus the job id, the quoted Skipping validation of types line, the Creating an optimized production build offset, the admin Finished TypeScript line and the 🩺 Verify Deployment result.

Rollback

Revert per SP4 (#554). The revert touches only apps/webapp/next.config.js, apps/webapp/docker/Dockerfile.bun and .github/workflows/prod.docs.plus.yml.

Stop condition: revert when any of these holds:

  • the first deploy with this change fails in 🏗️ Build Docker Images, and the error comes from the build argument or next.config.js;
  • the webapp containers fail their health check, or 🩺 Verify Deployment fails, after this change;
  • Build Verification stops printing Checking validity of types;
  • the Step 4 check shows the builder install no longer CACHED when only NEXT_SKIP_TYPECHECK changes.

Fix forward, do not revert, when the deploy is green but still prints Checking validity of types. The change is then a no-op. Find why the argument did not reach next build, and comment here.

No host step or setting change: nothing on the prod host stores NEXT_SKIP_TYPECHECK.

Docs to update

None. No doc says that the Docker build type-checks. No CHANGELOG entry: self-hosters see no change. The code comments in Steps 1–3 carry the reason.

Out of scope

Read first

Activity

  1. added this to the v2.3.0 milestone on Oct 20, 2026
  2. added
    Performance
    on Oct 20, 2026
  3. HMarzban commented on Oct 26, 2026

    @HMarzban
    CollaboratorAuthor

    Built and committed on local main. Awaits the maintainer's final push.

    Remaining gate: the push and the first (build): deploy. That run must show the type-check skip line, Build Verification, the admin type check and Verify Deployment. Then the Measured comment.

  4. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03. 975b9caca is pushed and deployed on 2026-11-03. Run 41608014517 behaved as planned:

    • The Docker webapp build prints Skipping validation of types.
    • Creating an optimized production build appears at 4.7 s.
    • Build Verification still prints Checking validity of types.
    • The admin build prints Finished TypeScript.

    Left:

    • Builder: post the SP3 Measured comment.
    • Builder: post the Step 4 cache-hit result (1, 1, 0, 1), which is only in the commit body.
  5. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-03.

    Measured, 2026-11-03
    Run: 41608014517, attempt 1
    On main: #555, #556, #557, #558, #559, #560, #561, #562, #563, #564, #565; partial #566 (a9688f030) and #568 (d9b6222fd)
    M1 598 | M2g 496 | M2i 509 | M3 445 | M4 7 | M5 59 | W 9 | free_gb 60 | cached_installs 0
    Expected: type-check phase ("Creating an optimized production build" offset) 6 s or less; M3 and M1 about 31 s lower, not judged from one deploy
    Verdict: keep
    

    Sources: Run Report job 125827136949. Build lines from Build Images job 125822892492. Health from Deploy Production job 125826444636.

    • Webapp next build (BuildKit step #105, job 125822892492):
      • #105 4.115 Skipping validation of types
      • #105 4.698 Creating an optimized production build ...
      • The offset is 4.698 s, at most 6 s. Pass. The baseline median was 34.7 s.
    • Admin build (#90, same job): #90 16.71 Finished TypeScript in 14.0s .... Pass.
    • Compose call: the job passes --build-arg "NEXT_SKIP_TYPECHECK=${NEXT_SKIP_TYPECHECK}" with NEXT_SKIP_TYPECHECK=1.
    • Build Verification, run 41608014517, job 125824373350: @docs.plus/webapp build:ci: Checking validity of types .... Pass. No PR carried this change, so this is the first push run on main.
    • 🩺 Verify Deployment: success. Its log prints ✅ webapp: 2 running, 2 healthy.
    • Support:
      • Run 41626334830, job 125884799321: Skipping validation of types, optimized build at 5.162 s, admin Finished TypeScript in 13.0s. BV job 125886115400 prints Checking validity of types.
      • Run 41636667896, job 125919866782: Skipping validation of types, optimized build at 3.798 s, admin Finished TypeScript in 11.5s. BV job 125921466487 prints Checking validity of types.
    • Step 4 cache-hit check, from the 975b9caca commit body: "Local Docker check (Step 4): 1, 1, 0, 1. The builder install stayed CACHED." Expected 1, 1, 0, 1. Pass.
    • Static items, read on HEAD:
      • next.config.js has one top-level typescript key with ignoreBuildErrors: process.env.NEXT_SKIP_TYPECHECK === '1'.
      • The Step 1 node checks print false, true and false.
      • Dockerfile.bun declares ARG NEXT_SKIP_TYPECHECK and its ENV at lines 219–220. That is below COPY apps/webapp ./apps/webapp (line 202) and above bunx next build (line 231).
      • actionlint reports no finding.
      • 975b9caca changes only three files. docker-compose.prod.yml is not one of them.
    • M3 445 and M1 598 are far below their baselines. Cut the webapp image installs from 158 s to about 25 s per deploy #559 and Build the deploy images while the quality gates run #565 landed in the same push, so this issue owns only the type-check phase.

    Can close now: yes

  6. modified the milestones: v2.3.0, v2.3.6 on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpsPerformance

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions