You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sources/platform/actors/development/actor_definition/docker.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,6 +204,48 @@ You can check out various optimization tips for Dockerfile in the [Performance](
204
204
205
205
:::
206
206
207
+
## Build TypeScript Actors
208
+
209
+
TypeScript Actors compile to JavaScript at build time through a `tsc` build step. Installing only production dependencies (`npm install --omit=dev`, or the older `--only=prod`) strips the `typescript` package, so the build fails with `tsc: not found`. Three fixes:
210
+
211
+
1. Multi-stage build (smallest runtime image, most complex Dockerfile). Installs dev dependencies in a builder stage, then copies the compiled output into a slim runtime stage.
1. Drop `--omit=dev` (simplest Dockerfile, largest runtime image). Installs everything, including linters and type declarations, into the single-stage image.
228
+
229
+
```dockerfile
230
+
FROM apify/actor-node:24
231
+
COPY --chown=myuser:myuser package*.json ./
232
+
RUN npm install
233
+
COPY --chown=myuser:myuser . ./
234
+
RUN npm run build
235
+
CMD ["node", "dist/main.js"]
236
+
```
237
+
238
+
1. Move `typescript` to `dependencies`. Keeps the single-stage Dockerfile but bloats the runtime image with the TypeScript compiler and its tooling. The runtime never uses these, so the extra size is wasted.
239
+
240
+
```json
241
+
{
242
+
"dependencies": {
243
+
"apify": "^3.4.0",
244
+
"typescript": "^5.5.0"
245
+
}
246
+
}
247
+
```
248
+
207
249
## Update older Dockerfiles
208
250
209
251
All Apify base Docker images now use a non-root user to enhance security. This change requires updates to existing Actor `Dockerfile`s that use the `apify/actor-node`, `apify/actor-python`, `apify/actor-python-playwright`, or `apify/actor-python-selenium` images. This section provides guidance on resolving common issues that may arise during this migration.
0 commit comments