Skip to content

Commit e6cf735

Browse files
authored
ci: multi arch builds and publish images to both repos (#9)
* chore: image metadata added * ci: multi arch build and publish to both repos
1 parent dc4e633 commit e6cf735

File tree

4 files changed

+143
-3
lines changed

4 files changed

+143
-3
lines changed

.github/workflows/build-and-release.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,24 @@ jobs:
3131
registry: ghcr.io
3232
username: ${{ github.actor }}
3333
password: ${{ secrets.GHCR_PAT }}
34+
- name: Configure AWS credentials
35+
uses: aws-actions/configure-aws-credentials@v4
36+
with:
37+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
38+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
39+
aws-region: us-east-1
40+
- name: Log in to Public ECR
41+
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
3442
- name: Build and push base
3543
run: |
3644
echo "${{ secrets.GHCR_PAT }}" > github_token
3745
docker buildx build \
38-
--platform linux/arm64 \
46+
--platform linux/arm64,linux/amd64 \
3947
--provenance=false \
4048
--secret id=github_token,src=github_token \
4149
--target base \
4250
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:base \
51+
--tag public.ecr.aws/j5r7n1v7/lambda-shell-runtime:base \
4352
--push \
4453
.
4554
env:
@@ -99,15 +108,35 @@ jobs:
99108
echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
100109
fi
101110
echo "Detected VERSION: $VERSION"
111+
- name: Configure AWS credentials
112+
uses: aws-actions/configure-aws-credentials@v4
113+
with:
114+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
115+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
116+
aws-region: us-east-1
102117
- name: Log in to GHCR
103118
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u skunxicat --password-stdin
119+
- name: Log in to Public ECR
120+
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
104121
- name: Build and push images
105122
run: |
106123
echo "${{ secrets.GHCR_PAT }}" > github_token
107124
export GITHUB_TOKEN="${{ secrets.GHCR_PAT }}"
108125
109-
# Build and push all variants
110-
make push VERSION="$VERSION" REGISTRY="ghcr.io/${{ github.repository_owner }}"
126+
# Build and push to both registries
127+
./build-enhanced --push --ghcr --public-ecr --platform linux/arm64,linux/amd64 tiny micro full
128+
129+
# Also tag latest for main branch releases
130+
if [ "${{ github.ref_name }}" = "main" ] && [ "$SHOULD_RELEASE" = "true" ]; then
131+
for VARIANT in tiny micro full; do
132+
docker buildx imagetools create \
133+
ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:$VARIANT \
134+
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:$VARIANT-latest
135+
docker buildx imagetools create \
136+
public.ecr.aws/j5r7n1v7/lambda-shell-runtime:$VARIANT \
137+
--tag public.ecr.aws/j5r7n1v7/lambda-shell-runtime:$VARIANT-latest
138+
done
139+
fi
111140
shell: bash
112141
- name: Create release
113142
if: env.SHOULD_RELEASE == 'true'

.github/workflows/build-installers.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ jobs:
2424
- name: Set up Docker Buildx
2525
uses: docker/setup-buildx-action@v3
2626

27+
- name: Configure AWS credentials
28+
uses: aws-actions/configure-aws-credentials@v4
29+
with:
30+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
31+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
32+
aws-region: us-east-1
2733
- name: Login to GitHub Container Registry
2834
uses: docker/login-action@v3
2935
with:
3036
registry: ghcr.io
3137
username: ${{ github.actor }}
3238
password: ${{ secrets.GHCR_PAT }}
39+
- name: Log in to Public ECR
40+
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
3341

3442
- name: Build and push installers
3543
run: |
@@ -39,6 +47,7 @@ jobs:
3947
--provenance=false \
4048
--target awscurl-installer \
4149
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:awscurl-installer \
50+
--tag public.ecr.aws/j5r7n1v7/lambda-shell-runtime:awscurl-installer \
4251
--push \
4352
-f - . << 'EOF'
4453
FROM public.ecr.aws/lambda/provided:al2023 AS awscurl-installer
@@ -55,6 +64,7 @@ jobs:
5564
--provenance=false \
5665
--target awscli-installer \
5766
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:awscli-installer \
67+
--tag public.ecr.aws/j5r7n1v7/lambda-shell-runtime:awscli-installer \
5868
--push \
5969
-f - . << 'EOF'
6070
FROM public.ecr.aws/lambda/provided:al2023 AS awscli-installer

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ COPY task/handler.sh handler.sh
4141

4242
LABEL org.opencontainers.image.source="https://github.com/ql4b/lambda-shell-runtime"
4343
LABEL org.opencontainers.image.version="${VERSION}"
44+
LABEL org.opencontainers.image.title="Lambda Shell Runtime"
45+
LABEL org.opencontainers.image.description="Custom AWS Lambda runtime for executing Bash functions as serverless applications"
46+
LABEL org.opencontainers.image.url="https://github.com/ql4b/lambda-shell-runtime"
47+
LABEL org.opencontainers.image.documentation="https://github.com/ql4b/lambda-shell-runtime#readme"
48+
LABEL org.opencontainers.image.vendor="QL4B"
49+
LABEL org.opencontainers.image.licenses="MIT"
50+
LABEL org.opencontainers.image.authors="QL4B <https://github.com/ql4b>"
51+
LABEL maintainer="QL4B <https://github.com/ql4b>"
4452

4553
# tiny: add lambda helper functions
4654
FROM ghcr.io/ql4b/lambda-shell-runtime:base AS tiny

build-enhanced

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Default config
6+
PLATFORM="linux/arm64"
7+
MODE="--load"
8+
TAG="lambda-shell-runtime"
9+
VERSION="${VERSION:-develop}"
10+
VARIANTS="base tiny micro full"
11+
REGISTRIES=""
12+
13+
# Parse arguments
14+
while [ $# -gt 0 ]; do
15+
case "$1" in
16+
--platform)
17+
PLATFORM="$2"
18+
shift 2
19+
;;
20+
--tag)
21+
TAG="$2"
22+
shift 2
23+
;;
24+
--push)
25+
MODE="--push"
26+
shift
27+
;;
28+
--load)
29+
MODE="--load"
30+
shift
31+
;;
32+
--registry)
33+
REGISTRIES="$REGISTRIES $2"
34+
shift 2
35+
;;
36+
--ghcr)
37+
REGISTRIES="$REGISTRIES ghcr.io/ql4b"
38+
shift
39+
;;
40+
--public-ecr)
41+
REGISTRIES="$REGISTRIES public.ecr.aws/j5r7n1v7"
42+
shift
43+
;;
44+
*)
45+
# Remaining arguments are variants
46+
VARIANTS="$*"
47+
break
48+
;;
49+
esac
50+
done
51+
52+
for VARIANT in $VARIANTS; do
53+
DOCKERFILE="./Dockerfile"
54+
TARGET="$VARIANT"
55+
56+
[ "$VARIANT" = "base" ] && TARGET="base"
57+
58+
echo "Building $VARIANT ($DOCKERFILE) with platform $PLATFORM..."
59+
60+
# Build tags
61+
if [ "$MODE" = "--push" ] && [ -n "$REGISTRIES" ]; then
62+
# For push mode, only use registry tags
63+
TAGS=""
64+
for REGISTRY in $REGISTRIES; do
65+
TAGS="$TAGS --tag $REGISTRY/$TAG:$VARIANT"
66+
if [ -n "$VERSION" ]; then
67+
TAGS="$TAGS --tag $REGISTRY/$TAG:$VARIANT-$VERSION"
68+
fi
69+
done
70+
else
71+
# For load mode, use local tags
72+
TAGS="--tag $TAG:$VARIANT"
73+
if [ -n "$VERSION" ]; then
74+
TAGS="$TAGS --tag $TAG:$VARIANT-$VERSION"
75+
fi
76+
fi
77+
78+
docker buildx build \
79+
--platform "$PLATFORM" \
80+
--provenance=false \
81+
--secret id=github_token,env=GITHUB_TOKEN \
82+
$TAGS \
83+
--file "$DOCKERFILE" \
84+
${TARGET:+--target "$TARGET"} \
85+
$MODE \
86+
.
87+
88+
# Only do local tagging for --load mode if version wasn't already tagged
89+
if [ -n "$VERSION" ] && [ "$MODE" = "--load" ]; then
90+
echo "Tagging $TAG:$VARIANT-$VERSION"
91+
docker tag $TAG:$VARIANT $TAG:$VARIANT-$VERSION
92+
fi
93+
done

0 commit comments

Comments
 (0)