Skip to content
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
8 changes: 6 additions & 2 deletions .github/scripts/prepare-node-image-tags.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = () => {
const { CURRENT_NODE, LATEST_NODE, RELEASE_TAG, IMAGE_NAME, FRAMEWORK_VERSION, IS_LATEST_BROWSER_IMAGE } = process.env
const { CURRENT_NODE, LATEST_NODE, RELEASE_TAG, IMAGE_NAME, FRAMEWORK_VERSION, IS_LATEST_BROWSER_IMAGE, TAG_SUFFIX } = process.env
const tags = [];
// Optional suffix appended to every tag (e.g. "-slim" -> apify/actor-node:20-slim).
const suffix = TAG_SUFFIX || '';

if (CURRENT_NODE === LATEST_NODE && IS_LATEST_BROWSER_IMAGE === 'true') {
// apify/actor-node-x:latest
Expand Down Expand Up @@ -31,5 +33,7 @@ module.exports = () => {
tags.push(`${IMAGE_NAME}:${CURRENT_NODE}-${RELEASE_TAG}`);
}

return { allTags: tags.join(','), firstImageName: tags[0] };
const suffixedTags = tags.map((tag) => `${tag}${suffix}`);

return { allTags: suffixedTags.join(','), firstImageName: suffixedTags[0] };
}
18 changes: 12 additions & 6 deletions .github/scripts/set-dependency-versions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs');

const PACKAGE_JSON_PATH = './package.json';
// package.slim.json is the manifest for the -slim image variants; keep it in sync.
const PACKAGE_JSON_PATHS = ['./package.json', './package.slim.json'];

const DEPENDENCY_VERSIONS = {
'apify': process.env.APIFY_VERSION,
Expand All @@ -13,19 +14,24 @@ const DEPENDENCY_VERSIONS = {
'camoufox-js': process.env.CAMOUFOX_VERSION,
};

const pkg = readPackageJson(PACKAGE_JSON_PATH);
updateDependencyVersions(pkg, DEPENDENCY_VERSIONS);
fs.writeFileSync(PACKAGE_JSON_PATH, JSON.stringify(pkg, null, 4));
for (const path of PACKAGE_JSON_PATHS) {
const pkg = readPackageJson(path);
if (!pkg) continue;
updateDependencyVersions(pkg, DEPENDENCY_VERSIONS);
fs.writeFileSync(path, JSON.stringify(pkg, null, 4));
}

function readPackageJson(path) {
try {
const pkgJson = fs.readFileSync(path, 'utf-8');
return JSON.parse(pkgJson);
} catch (err) {
if (err.code === 'ENOENT') {
console.log(`No package.json to update in ${process.cwd()}`);
process.exit(0);
console.log(`No ${path} to update in ${process.cwd()}`);
return undefined;
}

throw err;
}
}

Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/release-node-playwright.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ jobs:
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags();

- name: Prepare slim image tags
id: prepare-slim-tags
uses: actions/github-script@v8
env:
CURRENT_NODE: ${{ matrix.node-version }}
LATEST_NODE: ${{ matrix.latest-node-version }}
FRAMEWORK_VERSION: ${{ matrix.playwright-version }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
IMAGE_NAME: apify/actor-${{ matrix.image-name }}
IS_LATEST_BROWSER_IMAGE: ${{ matrix.is-latest }}
TAG_SUFFIX: "-slim"
with:
script: |
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags();

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand Down Expand Up @@ -240,6 +256,28 @@ jobs:
yarn cache dir | grep -q "^/pkg-cache/yarn"
'

- name: Build and tag slim image for testing
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
# PLAYWRIGHT_VERSION here is used for the full node-playwright image
build-args: |
NODE_VERSION=${{ matrix.node-version }}
PLAYWRIGHT_VERSION=${{ format('v{0}-', matrix.playwright-version) }}
SLIM=1
platforms: linux/amd64
provenance: false
load: true
tags: ${{ fromJson(steps.prepare-slim-tags.outputs.result).allTags }}
cache-from: |
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.playwright-version }}-slim
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.playwright-version }}
cache-to: type=gha,mode=max,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.playwright-version }}-slim

- name: Test slim image
run: docker run ${{ fromJson(steps.prepare-slim-tags.outputs.result).firstImageName }}

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
Expand All @@ -262,3 +300,22 @@ jobs:
tags: ${{ fromJson(steps.prepare-tags.outputs.result).allTags }}
outputs: type=image,oci-mediatypes=true
cache-from: type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.playwright-version }}

- name: Build and push slim OCI image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
build-args: |
NODE_VERSION=${{ matrix.node-version }}
PLAYWRIGHT_VERSION=${{ format('v{0}-', matrix.playwright-version) }}
SLIM=1
platforms: ${{ matrix.supports-arm64 == 'true' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
provenance: true
push: true
tags: ${{ fromJson(steps.prepare-slim-tags.outputs.result).allTags }}
outputs: type=image,oci-mediatypes=true
cache-from: |
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.playwright-version }}-slim
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.playwright-version }}
56 changes: 56 additions & 0 deletions .github/workflows/release-node-puppeteer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ jobs:
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags();

- name: Prepare slim image tags
id: prepare-slim-tags
uses: actions/github-script@v8
env:
CURRENT_NODE: ${{ matrix.node-version }}
LATEST_NODE: ${{ matrix.latest-node-version }}
FRAMEWORK_VERSION: ${{ matrix.puppeteer-version }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
IMAGE_NAME: apify/actor-${{ matrix.image-name }}
IS_LATEST_BROWSER_IMAGE: ${{ matrix.is-latest }}
TAG_SUFFIX: "-slim"
with:
script: |
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags();

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand Down Expand Up @@ -221,6 +237,27 @@ jobs:
yarn cache dir | grep -q "^/pkg-cache/yarn"
'

- name: Build and tag slim image for testing
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
build-args: |
NODE_VERSION=${{ matrix.node-version }}
PUPPETEER_VERSION=${{ matrix.puppeteer-version }}
SLIM=1
platforms: linux/amd64
provenance: false
load: true
tags: ${{ fromJson(steps.prepare-slim-tags.outputs.result).allTags }}
cache-from: |
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.puppeteer-version }}-slim
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.puppeteer-version }}
cache-to: type=gha,mode=max,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.puppeteer-version }}-slim

- name: Test slim image
run: docker run ${{ fromJson(steps.prepare-slim-tags.outputs.result).firstImageName }}

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
Expand All @@ -243,3 +280,22 @@ jobs:
tags: ${{ fromJson(steps.prepare-tags.outputs.result).allTags }}
outputs: type=image,oci-mediatypes=true
cache-from: type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.puppeteer-version }}

- name: Build and push slim OCI image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
build-args: |
NODE_VERSION=${{ matrix.node-version }}
PUPPETEER_VERSION=${{ matrix.puppeteer-version }}
SLIM=1
platforms: linux/amd64
provenance: true
push: true
tags: ${{ fromJson(steps.prepare-slim-tags.outputs.result).allTags }}
outputs: type=image,oci-mediatypes=true
cache-from: |
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.puppeteer-version }}-slim
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-${{ matrix.puppeteer-version }}
54 changes: 54 additions & 0 deletions .github/workflows/release-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ jobs:
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags();

- name: Prepare slim image tags
id: prepare-slim-tags
uses: actions/github-script@v8
env:
CURRENT_NODE: ${{ matrix.node-version }}
LATEST_NODE: ${{ matrix.latest-node-version }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
IMAGE_NAME: apify/actor-${{ matrix.image-name }}
# Force this to true, as these images have no browsers
IS_LATEST_BROWSER_IMAGE: "true"
TAG_SUFFIX: "-slim"
with:
script: |
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags();

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand Down Expand Up @@ -213,6 +229,26 @@ jobs:
yarn cache dir | grep -q "^/pkg-cache/yarn"
'

- name: Build and tag slim image for testing
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
build-args: |
NODE_VERSION=${{ matrix.node-version }}
SLIM=1
platforms: linux/amd64
provenance: false
load: true
tags: ${{ fromJson(steps.prepare-slim-tags.outputs.result).allTags }}
cache-from: |
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-slim
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}
cache-to: type=gha,mode=max,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-slim

- name: Test slim image
run: docker run ${{ fromJson(steps.prepare-slim-tags.outputs.result).firstImageName }}

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
Expand All @@ -233,3 +269,21 @@ jobs:
tags: ${{ fromJson(steps.prepare-tags.outputs.result).allTags }}
outputs: type=image,oci-mediatypes=true
cache-from: type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}

- name: Build and push slim OCI image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
build-args: |
NODE_VERSION=${{ matrix.node-version }}
SLIM=1
platforms: linux/amd64,linux/arm64
provenance: true
push: true
tags: ${{ fromJson(steps.prepare-slim-tags.outputs.result).allTags }}
outputs: type=image,oci-mediatypes=true
cache-from: |
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}-slim
type=gha,scope=${{ matrix.image-name }}-${{ matrix.node-version }}
Loading
Loading