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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Every change needs a review from a maintainer, including changes to .github/workflows/.
* @svozza @maxday
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
patterns:
- "*"
commit-message:
prefix: "ci"
open-pull-requests-limit: 5
143 changes: 143 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Builds the nodejs26.x mainline runtime image for arm64 and amd64, each on its own CodeBuild-hosted
# runner, and runs the smoke and security tests through the Runtime Interface Emulator. On a push it
# also pushes each image to ECR, tagged <commit>-<arch>, as the role that the deploy environment's
# OIDC token may assume.
#
# The CodeBuild label names the runner project; the extra labels override its instance size.
# The jobs are named build-<arch>, the status check names the main branch's ruleset requires.
# Repository variables:
# REGISTRY_MIRROR optional: an ECR pull-through cache of public.ecr.aws for the builder and
# base images (see build.sh). The runner's CodeBuild role pulls from it.
# NPM_REGISTRY optional: the URL of a CodeArtifact npm repository to install the npm
# packages from instead of the public registry. The runner's CodeBuild role
# gets its token.
name: Build runtime image

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name != 'push' }}

env:
ECR_REPOSITORY: aws-lambda-nodejs-runtime

jobs:
build:
name: build-${{ matrix.arch }}
strategy:
# A cancelled job shows as a failed check, so one architecture's failure does not cancel
# the other.
fail-fast: false
matrix:
include:
- arch: arm64
project: project-aws-aws-lambda-nodejs-runtime-arm64
- arch: amd64
project: project-aws-aws-lambda-nodejs-runtime-x86
runs-on:
- codebuild-${{ matrix.project }}-${{ github.run_id }}-${{ github.run_attempt }}
- instance-size:2xlarge
timeout-minutes: 120
environment: ${{ github.event_name == 'push' && 'deploy' || '' }}
# id-token lets the push steps request the OIDC token the ECR role trusts.
permissions:
contents: read
id-token: write
env:
BUILDKIT_PROGRESS: plain
ARCH: ${{ matrix.arch }}
IMAGE: lambda-runtime/image:nodejs26.x-mainline-${{ matrix.arch }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

# build.sh writes to the containerd image store and later builds read those images back
# as build contexts, which the classic image store cannot do.
- name: Use the containerd image store
run: |
if docker info -f '{{ .DriverStatus }}' | grep -q io.containerd.snapshotter; then exit 0; fi
mkdir -p /etc/docker
echo '{"features":{"containerd-snapshotter":true}}' > /etc/docker/daemon.json
pkill dockerd || true
while pgrep -x dockerd > /dev/null; do sleep 1; done
nohup dockerd > /tmp/dockerd.log 2>&1 &
for attempt in $(seq 60); do docker info > /dev/null 2>&1 && break; sleep 1; done
docker info -f '{{ .DriverStatus }}' | grep io.containerd.snapshotter
docker version
docker buildx version

- name: Log in to the registry mirror
if: vars.REGISTRY_MIRROR != ''
env:
REGISTRY_MIRROR: ${{ vars.REGISTRY_MIRROR }}
run: aws ecr get-login-password | docker login --username AWS --password-stdin "${REGISTRY_MIRROR%%/*}"

# The token is written to an npm config file in the job's temporary directory, which
# build.sh passes to the build as a secret.
- name: Configure the npm registry
if: vars.NPM_REGISTRY != ''
env:
NPM_REGISTRY: ${{ vars.NPM_REGISTRY }}
run: |
host=${NPM_REGISTRY#https://}
host=${host%%/*}
domain_and_owner=${host%%.d.codeartifact.*}
owner=${domain_and_owner##*-}
domain=${domain_and_owner%-*}
token=$(aws codeartifact get-authorization-token --domain "$domain" --domain-owner "$owner" \
--query authorizationToken --output text)
echo "::add-mask::$token"
npmrc="$RUNNER_TEMP/npmrc"
umask 077
printf 'registry=%s\n%s:_authToken=%s\n' "$NPM_REGISTRY" "${NPM_REGISTRY#https:}" "$token" > "$npmrc"
echo "NPMRC=$npmrc" >> "$GITHUB_ENV"

- name: Build the image
env:
REGISTRY_MIRROR: ${{ vars.REGISTRY_MIRROR }}
run: ./build.sh 26 "linux/$ARCH"

- name: Smoke-test the image
run: node test/run.mjs "$IMAGE" "linux/$ARCH"

- name: Security-test the image
run: node test/run.mjs "$IMAGE" "linux/$ARCH" test/security-cases.json

- name: Configure AWS credentials (OIDC)
if: github.event_name == 'push'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Log in to Amazon ECR
if: github.event_name == 'push'
id: login-ecr
uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7

- name: Push the image
if: github.event_name == 'push'
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# Tags are immutable, so a commit's image is pushed once; a re-run skips the push.
run: |
tag="$GITHUB_SHA-$ARCH"
if existing=$(aws ecr describe-images --repository-name "$ECR_REPOSITORY" --image-ids imageTag="$tag" \
--query 'imageDetails[0].imageDigest' --output text 2> /tmp/describe-images.err); then
echo "$ECR_REPOSITORY:$tag is already published as $existing"
exit 0
fi
grep -q ImageNotFoundException /tmp/describe-images.err || { cat /tmp/describe-images.err >&2; exit 1; }
image="$ECR_REGISTRY/$ECR_REPOSITORY:$tag"
docker tag "$IMAGE" "$image"
docker push "$image"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore the `build/` directory in the package root.
/build
Loading