diff --git a/sources/academy/platform/deploying_your_code/docker_file.md b/sources/academy/platform/deploying_your_code/docker_file.md index df853c6028..98546261c2 100644 --- a/sources/academy/platform/deploying_your_code/docker_file.md +++ b/sources/academy/platform/deploying_your_code/docker_file.md @@ -35,7 +35,7 @@ At the base level, each Docker image contains a base operating system and usuall Once you find the base image you need, you can add it as the initial `FROM` statement: ```Dockerfile -FROM apify/actor-node:16 +FROM apify/actor-node:24 ``` :::tip VSCode extension @@ -60,7 +60,7 @@ Here's the Dockerfile for our Node.js example project's Actor: ```Dockerfile -FROM apify/actor-node:16 +FROM apify/actor-node:24 # Second, copy just package.json and package-lock.json since they are the only files # that affect npm install in the next step @@ -90,7 +90,7 @@ COPY . ./ ```Dockerfile # First, specify the base Docker image. # You can also use any other image from Docker Hub. -FROM apify/actor-python:3.9 +FROM apify/actor-python:3.14 # Second, copy just requirements.txt into the Actor image, # since it should be the only file that affects "pip install" in the next step, diff --git a/sources/platform/actors/development/actor_definition/docker.md b/sources/platform/actors/development/actor_definition/docker.md index 41beccd6b1..b22a717567 100644 --- a/sources/platform/actors/development/actor_definition/docker.md +++ b/sources/platform/actors/development/actor_definition/docker.md @@ -23,7 +23,15 @@ All Apify Docker images are pre-cached on Apify servers to speed up Actor builds ### Node.js base images -These images come with Node.js (versions `20`, `22`, or `24`) the [Apify SDK for JavaScript](/sdk/js), and [Crawlee](https://crawlee.dev/) preinstalled. The `latest` tag corresponds to the latest LTS version of Node.js. +These images come with Node.js (versions `22`, `24`, or `26`). The `latest` tag corresponds to the latest LTS version of Node.js. + +Every image is published in two flavours. The full image preinstalls the [Apify SDK for JavaScript](/sdk/js), [Crawlee](https://crawlee.dev/) and TypeScript. The `-slim` variant (e.g. `24-slim`, `24-1.60.0-slim`) only ships the browser automation library the image is built around (for example `puppeteer` or `playwright`), and `actor-node:24-slim` ships no npm packages at all. Slim images are smaller and faster to pull, and your `package.json` is the single source of truth for dependency versions. + +Use the slim variant unless you have a reason not to. Reach for the full image when you want to run something quickly without maintaining a `package.json`, or when you rely on the exact preinstalled versions of `apify` and `crawlee`. + +```dockerfile +FROM apify/actor-node-playwright-chrome:24-1.60.0-slim +``` | Image | Description | | ----- | ----------- | @@ -33,17 +41,19 @@ These images come with Node.js (versions `20`, `22`, or `24`) the [Apify SDK for | [`actor-node-playwright-firefox`](https://hub.docker.com/r/apify/actor-node-playwright-firefox/) | Debian image with Firefox and the [`playwright`](https://github.com/microsoft/playwright) library . | | [`actor-node-playwright-webkit`](https://hub.docker.com/r/apify/actor-node-playwright-webkit/) | Ubuntu image with WebKit and the [`playwright`](https://github.com/microsoft/playwright) library. | | [`actor-node-playwright`](https://hub.docker.com/r/apify/actor-node-playwright/) | Ubuntu image with [`playwright`](https://github.com/microsoft/playwright) and all its browsers (Chromium, Google Chrome, Firefox, WebKit). | +| [`actor-node-playwright-camoufox`](https://hub.docker.com/r/apify/actor-node-playwright-camoufox/) | Debian image with [Camoufox](https://camoufox.com/), a Firefox fork hardened against bot detection, and the [`playwright`](https://github.com/microsoft/playwright), [`camoufox-js`](https://github.com/apify/camoufox-js) and [`impit`](https://github.com/apify/impit) libraries. | See the [Docker image guide](/sdk/js/docs/guides/docker-images) for more details. ### Python base images -These images come with Python (version `3.9`, `3.10`, `3.11`, `3.12`, or `3.13`) and the [Apify SDK for Python](/sdk/python) preinstalled. The `latest` tag corresponds to the latest Python 3 version supported by the Apify SDK. +These images come with Python (version `3.10`, `3.11`, `3.12`, `3.13`, or `3.14`) and the [Apify SDK for Python](/sdk/python) preinstalled. The `latest` tag corresponds to the latest Python 3 version supported by the Apify SDK. | Image | Description | | ----- | ----------- | | [`actor-python`](https://hub.docker.com/r/apify/actor-python) | Slim Debian image with only the Apify SDK for Python. Does not include headless browsers. | | [`actor-python-playwright`](https://hub.docker.com/r/apify/actor-python-playwright) | Debian image with [`playwright`](https://github.com/microsoft/playwright) and all its browsers. | +| [`actor-python-playwright-camoufox`](https://hub.docker.com/r/apify/actor-python-playwright-camoufox) | Debian image with [Camoufox](https://camoufox.com/), a Firefox fork hardened against bot detection, and the [`playwright`](https://github.com/microsoft/playwright) library. | | [`actor-python-selenium`](https://hub.docker.com/r/apify/actor-python-selenium) | Debian image with [`selenium`](https://github.com/seleniumhq/selenium), Google Chrome, and [ChromeDriver](https://developer.chrome.com/docs/chromedriver/). | ## Image tag naming convention @@ -54,23 +64,25 @@ Docker image tags follow a consistent naming pattern that allows you to pin spec For Node.js images, the tag format is: -- `{node-version}` - A Node.js version only (e.g., `20`, `22`, `24`) +- `{node-version}` - A Node.js version only (e.g., `22`, `24`, `26`) - `{node-version}-{library-version}` - A Node.js version with pinned Playwright/Puppeteer version (e.g., `22-1.52.0`) +- `{...}-slim` - Any of the above without preinstalled `apify`, `crawlee` and `typescript` (e.g., `24-slim`, `22-1.52.0-slim`) Examples: | Tag | Description | | --- | ----------- | -| `20` | Node.js 20 with the Playwright/Puppeteer version that was latest when the image was built | | `22` | Node.js 22 with the Playwright/Puppeteer version that was latest when the image was built | +| `24` | Node.js 24 with the Playwright/Puppeteer version that was latest when the image was built | | `22-1.52.0` | Node.js 22 with Playwright/Puppeteer version 1.52.0 pinned | +| `22-1.52.0-slim` | Same as `22-1.52.0`, but without preinstalled `apify`, `crawlee` and `typescript` | | `latest` | Latest LTS Node.js version | ### Python images For Python images, the tag format is: -- `{python-version}` - A Python version only (e.g., `3.11`, `3.12`, `3.13`) +- `{python-version}` - A Python version only (e.g., `3.12`, `3.13`, `3.14`) - `{python-version}-{library-version}` - A Python version with pinned Playwright/Selenium version ### Available tags @@ -141,6 +153,34 @@ The asterisk (`*`) tells npm to use whatever version is already installed, which 1. Predictability - You know exactly which version you're running 1. Debugging - Version-specific issues are easier to track down +## Node.js package managers + +All Node.js images ship with npm and have [Corepack](https://github.com/nodejs/corepack) enabled, so you can use yarn or pnpm as well. Neither is preinstalled: add a [`packageManager`](https://nodejs.org/api/packages.html#packagemanager) field to your `package.json` and Corepack downloads and uses the exact version you pin. + +```json +{ + "packageManager": "pnpm@10.24.0" +} +``` + +The images preconfigure the package managers so that: + +- pnpm and yarn install a flat, npm-style `node_modules` (`node-linker=hoisted` for pnpm, `nodeLinker: node-modules` for yarn) instead of a symlinked store or Plug'n'Play, so dependencies resolve without extra loaders. +- The yarn and pnpm caches (`YARN_CACHE_FOLDER`, `YARN_GLOBAL_FOLDER`, `PNPM_CONFIG_STORE_DIR`, `PNPM_CONFIG_CACHE_DIR`) and the Corepack cache (`COREPACK_HOME`) live under `/pkg-cache`. npm keeps its default `~/.npm` cache. Both directories only hold throwaway data, so you can `rm -rf /pkg-cache/* ~/.npm` at the end of your `Dockerfile` to reclaim space without touching installed dependencies. + +:::note Overriding the linker + +The images set the linker through the `PNPM_CONFIG_NODE_LINKER` and `YARN_NODE_LINKER` environment variables. Both pnpm and yarn give environment variables precedence over `.npmrc` or `.yarnrc.yml`, so a config file alone does not change the linker. To use a different one, override the variable in your `Dockerfile`: + +```dockerfile +# https://pnpm.io/settings#nodelinker +ENV PNPM_CONFIG_NODE_LINKER=isolated +# https://yarnpkg.com/configuration/yarnrc#nodeLinker +ENV YARN_NODE_LINKER=pnp +``` + +::: + ## Custom Dockerfile Apify uses Docker to build and run Actors. If you create an Actor from a template, it already contains an optimized `Dockerfile` for the given use case. diff --git a/sources/platform/actors/development/actor_definition/source_code.md b/sources/platform/actors/development/actor_definition/source_code.md index 4bd1f69ee7..5016f8a7bd 100644 --- a/sources/platform/actors/development/actor_definition/source_code.md +++ b/sources/platform/actors/development/actor_definition/source_code.md @@ -15,7 +15,7 @@ You have the flexibility to choose any programming language, technologies, and d Let's take a look at the example JavaScript Actor's source code. The following Dockerfile: ```dockerfile -FROM apify/actor-node:20 +FROM apify/actor-node:24 COPY package*.json ./ @@ -36,10 +36,10 @@ CMD npm start --silent This `Dockerfile` does the following tasks: -1. Builds the Actor from the `apify/actor-node:20` base image. +1. Builds the Actor from the `apify/actor-node:24` base image. ```dockerfile - FROM apify/actor-node:20 + FROM apify/actor-node:24 ``` 2. Copies the `package.json` and `package-lock.json` files to the image. diff --git a/sources/platform/actors/development/performance.md b/sources/platform/actors/development/performance.md index 5035bb6d28..3706d2c42b 100644 --- a/sources/platform/actors/development/performance.md +++ b/sources/platform/actors/development/performance.md @@ -23,7 +23,7 @@ When you build a Docker image, Docker caches the layers that haven't changed. Th Consider the following Dockerfile: ```dockerfile -FROM apify/actor-node:16 +FROM apify/actor-node:24 COPY package*.json ./