Skip to content

Commit a035af9

Browse files
author
Fabiana Severin
committed
ci(ric): pull JNI base images via ECR pull-through cache
1 parent e638ff9 commit a035af9

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

.github/workflows/release-runtime-interface-client.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ env:
4040
MAVEN_ARGS: "-B --no-transfer-progress"
4141
AWS_REGION: ${{ vars.AWS_REGION_MAVEN_RELEASE }}
4242
OIDC_ROLE_ARN: ${{ secrets.AWS_ROLE_MAVEN_RELEASE }}
43+
# ECR pull-through cache used for the native JNI base images. ECR_REGISTRY is
44+
# the login target; BASE_REGISTRY (with the /ecr-public prefix) is passed to
45+
# the Dockerfiles as a build-arg.
46+
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION_MAVEN_RELEASE }}.amazonaws.com
47+
BASE_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION_MAVEN_RELEASE }}.amazonaws.com/ecr-public
4348

4449
jobs:
4550
# Build each architecture's native libs (glibc + musl) on a native runner.
@@ -103,6 +108,14 @@ jobs:
103108
module: ${{ env.MODULE }}
104109
release-version-override: ${{ env.RELEASE_VERSION_INPUT }}
105110

111+
# The native JNI build shells out to `docker build` against the ECR
112+
# pull-through cache (see src/main/jni/Dockerfile.*). Authenticate first so
113+
# the base-image pulls don't hit public.ecr.aws. Uses ambient runner creds.
114+
- name: Log in to Amazon ECR (pull-through cache)
115+
run: |
116+
aws ecr get-login-password --region "$AWS_REGION" \
117+
| docker login --username AWS --password-stdin "$ECR_REGISTRY"
118+
106119
# -DskipTests: only installed so the module compiles, not released here.
107120
- name: Install intra-repo dependencies
108121
run: |
@@ -185,6 +198,14 @@ jobs:
185198
module: ${{ env.MODULE }}
186199
release-version-override: ${{ env.RELEASE_VERSION_INPUT }}
187200

201+
# The native JNI build shells out to `docker build` against the ECR
202+
# pull-through cache (see src/main/jni/Dockerfile.*). Authenticate first so
203+
# the base-image pulls don't hit public.ecr.aws. Uses ambient runner creds.
204+
- name: Log in to Amazon ECR (pull-through cache)
205+
run: |
206+
aws ecr get-login-password --region "$AWS_REGION" \
207+
| docker login --username AWS --password-stdin "$ECR_REGISTRY"
208+
188209
- name: Resolve next development version and tag
189210
run: |
190211
# Next development version: use the override, or bump the patch.

aws-lambda-java-runtime-interface-client/src/main/jni/Dockerfile.glibc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM public.ecr.aws/amazonlinux/amazonlinux:2
1+
ARG BASE_REGISTRY=public.ecr.aws
2+
FROM ${BASE_REGISTRY}/amazonlinux/amazonlinux:2
23

34
ARG CURL_VERSION
45

aws-lambda-java-runtime-interface-client/src/main/jni/Dockerfile.musl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM public.ecr.aws/docker/library/alpine:3
1+
ARG BASE_REGISTRY=public.ecr.aws
2+
FROM ${BASE_REGISTRY}/docker/library/alpine:3
23

34
ARG CURL_VERSION
45

aws-lambda-java-runtime-interface-client/src/main/jni/build-jni-lib.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ MULTI_ARCH=${2}
99
BUILD_OS=${3}
1010
BUILD_ARCH=${4}
1111
CURL_VERSION=7.83.1
12+
# Registry hosting the base images. Defaults to public.ecr.aws for local and
13+
# GitHub-hosted builds; the release workflow overrides it with the ECR
14+
# pull-through cache so egress-locked runners don't hit public.ecr.aws.
15+
BASE_REGISTRY="${BASE_REGISTRY:-public.ecr.aws}"
1216

1317
function get_docker_platform() {
1418
arch=$1
@@ -45,7 +49,7 @@ function build_for_libc_arch() {
4549

4650
if [[ "${MULTI_ARCH}" == "true" ]]; then
4751
docker build --platform="${docker_platform}" -f "${SRC_DIR}/Dockerfile.${libc_impl}" \
48-
--build-arg CURL_VERSION=${CURL_VERSION} "${SRC_DIR}" -o - \
52+
--build-arg CURL_VERSION=${CURL_VERSION} --build-arg BASE_REGISTRY=${BASE_REGISTRY} "${SRC_DIR}" -o - \
4953
| tar -xOf - src/aws-lambda-runtime-interface-client.so > "${artifact}"
5054
else
5155
echo "multi-arch not requested, assuming this is a workaround to goofyness when docker buildx is enabled on Linux CI environments."
@@ -63,7 +67,7 @@ function build_for_libc_arch() {
6367
docker build --platform="${docker_platform}" \
6468
-t "${image_name}" \
6569
-f "${SRC_DIR}/Dockerfile.${libc_impl}" \
66-
--build-arg CURL_VERSION=${CURL_VERSION} "${SRC_DIR}" ${EXTRA_LOAD_ARG}
70+
--build-arg CURL_VERSION=${CURL_VERSION} --build-arg BASE_REGISTRY=${BASE_REGISTRY} "${SRC_DIR}" ${EXTRA_LOAD_ARG}
6771

6872
echo "Docker image has been successfully built"
6973

0 commit comments

Comments
 (0)