docs(dockerfile): warn about the npm omit=dev + tsc build trap in TypeScript Actors#2716
Open
DaveHanns wants to merge 5 commits into
Open
docs(dockerfile): warn about the npm omit=dev + tsc build trap in TypeScript Actors#2716DaveHanns wants to merge 5 commits into
DaveHanns wants to merge 5 commits into
Conversation
…eScript Actors The canonical Node.js Dockerfile on this page uses `npm install --omit=dev`, which drops `devDependencies` and thus removes `typescript` from the image. Any TypeScript Actor whose `build` script invokes `tsc` will fail inside the Docker build with `tsc: not found`. This is a recurring pitfall — agents and users both hit it once per new TS Actor, and each retry burns a remote build cycle. Add a `:::warning` callout under the sample Dockerfile with two concrete fixes (multi-stage build, or single-stage with devDeps kept in) and the failure signature so it can be recognized from logs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
❌ Preview build for this PR (commit |
4 tasks
Cut the multi-stage code sample and the redundant symptoms paragraph; link to the ts-empty template's Dockerfile as the canonical multi-stage reference. Failure signature is still in the callout so log searches land here. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop the template reference; simplify the error signature to `tsc: not found`; add the "move typescript to dependencies" fix alongside multi-stage and drop-omit-dev. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Each of the three fixes (multi-stage, drop --omit=dev, move to dependencies) now has a one-line trade-off summary and a <details>-collapsed code example. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Remove specific runtime-image size numbers from the "move typescript to dependencies" fix; unspace em-dashes per Microsoft.Dashes vale rule. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
TC-MO
reviewed
Jul 13, 2026
TC-MO
left a comment
Contributor
There was a problem hiding this comment.
This should fix the build, I'll tackle the admonition itself separately
Comment on lines
+86
to
+103
| - **Multi-stage build** (smallest runtime image)—installs devDeps in a builder stage, copies the compiled output into a slim runtime stage. Most complex Dockerfile. | ||
| <details><summary>Example</summary> | ||
|
|
||
| ```dockerfile | ||
| FROM apify/actor-node:24 AS builder | ||
| COPY --chown=myuser:myuser package*.json ./ | ||
| RUN npm install --include=dev | ||
| COPY --chown=myuser:myuser . ./ | ||
| RUN npm run build | ||
|
|
||
| FROM apify/actor-node:24 | ||
| COPY --chown=myuser:myuser package*.json ./ | ||
| RUN npm install --omit=dev --omit=optional | ||
| COPY --from=builder --chown=myuser:myuser /usr/src/app/dist ./dist | ||
| CMD ["node", "dist/main.js"] | ||
| ``` | ||
|
|
||
| </details> |
Contributor
There was a problem hiding this comment.
Suggested change
| - **Multi-stage build** (smallest runtime image)—installs devDeps in a builder stage, copies the compiled output into a slim runtime stage. Most complex Dockerfile. | |
| <details><summary>Example</summary> | |
| ```dockerfile | |
| FROM apify/actor-node:24 AS builder | |
| COPY --chown=myuser:myuser package*.json ./ | |
| RUN npm install --include=dev | |
| COPY --chown=myuser:myuser . ./ | |
| RUN npm run build | |
| FROM apify/actor-node:24 | |
| COPY --chown=myuser:myuser package*.json ./ | |
| RUN npm install --omit=dev --omit=optional | |
| COPY --from=builder --chown=myuser:myuser /usr/src/app/dist ./dist | |
| CMD ["node", "dist/main.js"] | |
| ``` | |
| </details> | |
| - **Multi-stage build** (smallest runtime image)—installs devDeps in a builder stage, copies the compiled output into a slim runtime stage. Most complex Dockerfile. | |
| <details> | |
| <summary>Example</summary> | |
| ```dockerfile | |
| FROM apify/actor-node:24 AS builder | |
| COPY --chown=myuser:myuser package*.json ./ | |
| RUN npm install --include=dev | |
| COPY --chown=myuser:myuser . ./ | |
| RUN npm run build | |
| FROM apify/actor-node:24 | |
| COPY --chown=myuser:myuser package*.json ./ | |
| RUN npm install --omit=dev --omit=optional | |
| COPY --from=builder --chown=myuser:myuser /usr/src/app/dist ./dist | |
| CMD ["node", "dist/main.js"] |
Comment on lines
+105
to
+117
| - **Drop `--omit=dev`** (simplest Dockerfile, largest runtime image)—installs everything, including linters and type declarations, into the single-stage image. | ||
| <details><summary>Example</summary> | ||
|
|
||
| ```dockerfile | ||
| FROM apify/actor-node:24 | ||
| COPY --chown=myuser:myuser package*.json ./ | ||
| RUN npm install | ||
| COPY --chown=myuser:myuser . ./ | ||
| RUN npm run build | ||
| CMD ["node", "dist/main.js"] | ||
| ``` | ||
|
|
||
| </details> |
Contributor
There was a problem hiding this comment.
Suggested change
| - **Drop `--omit=dev`** (simplest Dockerfile, largest runtime image)—installs everything, including linters and type declarations, into the single-stage image. | |
| <details><summary>Example</summary> | |
| ```dockerfile | |
| FROM apify/actor-node:24 | |
| COPY --chown=myuser:myuser package*.json ./ | |
| RUN npm install | |
| COPY --chown=myuser:myuser . ./ | |
| RUN npm run build | |
| CMD ["node", "dist/main.js"] | |
| ``` | |
| </details> | |
| - **Drop `--omit=dev`** (simplest Dockerfile, largest runtime image)—installs everything, including linters and type declarations, into the single-stage image. | |
| <details> | |
| <summary>Example</summary> | |
| ```dockerfile | |
| FROM apify/actor-node:24 | |
| COPY --chown=myuser:myuser package*.json ./ | |
| RUN npm install | |
| COPY --chown=myuser:myuser . ./ | |
| RUN npm run build | |
| CMD ["node", "dist/main.js"] |
Comment on lines
+119
to
+131
| - **Move `typescript` to `dependencies`**—keeps the single-stage Dockerfile but bloats the runtime image with the TypeScript compiler and its tooling. Runtime never uses these, so the extra size is wasted. | ||
| <details><summary>Example</summary> | ||
|
|
||
| ```json | ||
| { | ||
| "dependencies": { | ||
| "apify": "^3.4.0", | ||
| "typescript": "^5.5.0" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </details> |
Contributor
There was a problem hiding this comment.
Suggested change
| - **Move `typescript` to `dependencies`**—keeps the single-stage Dockerfile but bloats the runtime image with the TypeScript compiler and its tooling. Runtime never uses these, so the extra size is wasted. | |
| <details><summary>Example</summary> | |
| ```json | |
| { | |
| "dependencies": { | |
| "apify": "^3.4.0", | |
| "typescript": "^5.5.0" | |
| } | |
| } | |
| ``` | |
| </details> | |
| - **Move `typescript` to `dependencies`**—keeps the single-stage Dockerfile but bloats the runtime image with the TypeScript compiler and its tooling. Runtime never uses these, so the extra size is wasted. | |
| <details> | |
| <summary>Example</summary> | |
| ```json | |
| { | |
| "dependencies": { | |
| "apify": "^3.4.0", | |
| "typescript": "^5.5.0" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
:::warningonsource_code.mdabout thenpm install --omit=dev+tscbuild trap:--omit=devdropstypescript, so any TS Actor whosebuildinvokestscfails at image-build time withsh: tsc: not found. Callout links to the ts-empty template's Dockerfile as the canonical multi-stage reference.Related — coordinated remediation stack
Four defense layers, each covering a different failure mode:
apify/actor-templates— ts-* Dockerfiles ship a multi-stage build (already in master via #592, Dec 2025). Users ofapify create -t ts-*cannot hit the trap.apify/apify-cli#1252—apify pushpreflight warning when a Dockerfile has--omit=devbeforenpm run buildthat invokestsc.apify/apify-cli#1261—apify createforces--include=dev+NODE_ENV=developmenton the post-scaffold install, soapify runworks locally.docker build/ search-fallback case.Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.