Skip to content

Commit ceb6279

Browse files
committed
chore(ci): add base image build step to release workflow
1 parent 84a85a9 commit ceb6279

File tree

6 files changed

+59
-98
lines changed

6 files changed

+59
-98
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ jobs:
4444
restore-keys: |
4545
${{ runner.os }}-buildx-
4646
- name: Build Docker images
47-
run: |
47+
run: |
4848
echo "${{ secrets.GHCR_PAT }}" > github_token
4949
export DOCKER_BUILDKIT=1
50+
51+
docker buildx build --builder shell-runtime-builder --platform linux/arm64 \
52+
--build-arg HTTP_CLI_VERSION=${{ env.HTTP_CLI_VERSION }} \
53+
--output type=docker --progress=plain \
54+
--secret id=github_token,src=github_token \
55+
--cache-from type=local,src=/tmp/.buildx-cache \
56+
--cache-to type=local,dest=/tmp/.buildx-cache \
57+
-t lambda-shell-runtime:base -f base.Dockerfile .
58+
5059
docker buildx build --builder shell-runtime-builder --platform linux/arm64 \
5160
--build-arg HTTP_CLI_VERSION=${{ env.HTTP_CLI_VERSION }} \
5261
--output type=docker --progress=plain \

Dockerfile

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
1-
# Stage 1: Build stage
2-
FROM public.ecr.aws/lambda/provided:al2023 AS builder
3-
4-
ARG HTTP_CLI_VERSION=v1.0.1
5-
6-
RUN dnf install -y unzip && \
7-
dnf clean all
8-
9-
# Download http-cli
10-
RUN --mount=type=secret,id=github_token \
11-
curl -H "Authorization: token $(cat /run/secrets/github_token)" \
12-
-L "https://github.com/ql4b/http-cli/archive/refs/tags/${HTTP_CLI_VERSION}.zip" \
13-
-o http-cli.zip && \
14-
unzip http-cli.zip && \
15-
mkdir -p /http-cli-bin && \
16-
mv http-cli-${HTTP_CLI_VERSION#v}/http-cli /http-cli-bin/ && \
17-
chmod +x /http-cli-bin/http-cli && \
18-
rm -rf http-cli.zip http-cli-${HTTP_CLI_VERSION#v}
19-
20-
21-
FROM public.ecr.aws/lambda/provided:al2023
1+
FROM lamda-shell-runtime:tiny
222

233
RUN dnf install -y \
244
jq \
255
aws-cli && \
266
dnf clean all && \
277
rm -rf /var/cache/dnf
28-
29-
# Copy http-cli
30-
COPY --from=builder /http-cli-bin/http-cli /var/task/bin/http-cli
31-
32-
ENV PATH="/var/task/bin:${PATH}"
33-
34-
COPY runtime/bootstrap /var/runtime/bootstrap
35-
RUN chmod +x /var/runtime/bootstrap
36-
37-
WORKDIR /var/task
38-
39-
COPY task/handler.sh handler.sh
40-
COPY task/helpers.sh helpers.sh

base.Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM public.ecr.aws/lambda/provided:al2023 AS builder
2+
3+
ARG HTTP_CLI_VERSION=v1.0.1
4+
5+
RUN dnf install -y unzip && \
6+
dnf clean all
7+
8+
# Download http-cli
9+
RUN --mount=type=secret,id=github_token \
10+
curl -H "Authorization: token $(cat /run/secrets/github_token)" \
11+
-L "https://github.com/ql4b/http-cli/archive/refs/tags/${HTTP_CLI_VERSION}.zip" \
12+
-o http-cli.zip && \
13+
unzip http-cli.zip && \
14+
mkdir -p /http-cli-bin && \
15+
mv http-cli-${HTTP_CLI_VERSION#v}/http-cli /http-cli-bin/ && \
16+
chmod +x /http-cli-bin/http-cli && \
17+
rm -rf http-cli.zip http-cli-${HTTP_CLI_VERSION#v}
18+
19+
FROM public.ecr.aws/lambda/provided:al2023 AS base
20+
21+
# Install only runtime dependencies
22+
RUN dnf install -y jq && \
23+
dnf clean all && \
24+
rm -rf /var/cache/dnf
25+
26+
# Copy http-cli
27+
COPY --from=builder /http-cli-bin/http-cli /var/task/bin/http-cli
28+
ENV PATH="/var/task/bin:${PATH}"
29+
30+
COPY runtime/bootstrap /var/runtime/bootstrap
31+
RUN chmod +x /var/runtime/bootstrap
32+
33+
WORKDIR /var/task
34+
35+
COPY task/handler.sh handler.sh
36+
37+
# Label for documentation/reference
38+
LABEL org.opencontainers.image.title="lambda-shell-runtime:base"

build

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
#!/bin/sh
33

4-
set -e
4+
set -ex
55

66
# Default config
77
PLATFORM="linux/arm64"
88
MODE="--load"
99
TAG="lambda-shell-runtime"
10-
VARIANTS="tiny micro full"
10+
VARIANTS="base tiny micro full"
1111

1212
# Parse arguments
1313
while [ $# -gt 0 ]; do
@@ -28,7 +28,7 @@ while [ $# -gt 0 ]; do
2828
MODE="--load"
2929
shift
3030
;;
31-
tiny|slim|full)
31+
full|tiny|micro|base)
3232
VARIANTS="$1"
3333
shift
3434
;;
@@ -43,6 +43,8 @@ for VARIANT in $VARIANTS; do
4343
DOCKERFILE="./${VARIANT}.Dockerfile"
4444
[ "$VARIANT" = "full" ] && DOCKERFILE="./Dockerfile"
4545

46+
[ "$VARIANT" = "base" ] && MODE="--load"
47+
4648
echo "Building $VARIANT ($DOCKERFILE) with platform $PLATFORM..."
4749
docker buildx build \
4850
--platform "$PLATFORM" \

micro.Dockerfile

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
FROM public.ecr.aws/lambda/provided:al2023 AS builder
22

3-
ARG HTTP_CLI_VERSION=v1.0.1
4-
53
RUN dnf install -y unzip python3-pip findutils && \
64
dnf clean all
75

8-
# Download http-cli
9-
RUN --mount=type=secret,id=github_token \
10-
curl -H "Authorization: token $(cat /run/secrets/github_token)" \
11-
-L "https://github.com/ql4b/http-cli/archive/refs/tags/${HTTP_CLI_VERSION}.zip" \
12-
-o http-cli.zip && \
13-
unzip http-cli.zip && \
14-
mkdir -p /http-cli-bin && \
15-
mv http-cli-${HTTP_CLI_VERSION#v}/http-cli /http-cli-bin/ && \
16-
chmod +x /http-cli-bin/http-cli && \
17-
rm -rf http-cli.zip http-cli-${HTTP_CLI_VERSION#v}
18-
196
RUN pip3 install --no-cache-dir --target /tmp/awscurl awscurl && \
207
find /tmp/awscurl -type d -name '__pycache__' -exec rm -rf {} + && \
218
find /tmp/awscurl -type f -name '*.pyc' -delete && \
229
find /tmp/awscurl -type d -name '*.dist-info' -exec rm -rf {} +
2310

2411
# Stage 2: Runtime stage
25-
FROM public.ecr.aws/lambda/provided:al2023
12+
FROM lambda-shell-runtime:tiny AS micro
2613

2714
# Install only runtime dependencies
2815
RUN dnf install -y jq python3 && \
@@ -43,14 +30,4 @@ RUN mkdir -p /var/task/bin && \
4330
printf '#!/bin/sh\nexport PYTHONPATH=/var/task/aws\nexec python3 -m awscurl.awscurl "$@"\n' > /var/task/bin/awscurl && \
4431
chmod +x /var/task/bin/awscurl
4532

46-
# Copy http-cli
47-
COPY --from=builder /http-cli-bin/http-cli /var/task/bin/http-cli
48-
ENV PATH="/var/task/bin:${PATH}"
49-
50-
COPY runtime/bootstrap /var/runtime/bootstrap
51-
RUN chmod +x /var/runtime/bootstrap
52-
53-
WORKDIR /var/task
54-
55-
COPY task/handler.sh handler.sh
56-
COPY task/helpers.sh helpers.sh
33+
LABEL org.opencontainers.image.title="lambda-shell-runtime:micro"

tiny.Dockerfile

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,5 @@
1-
FROM public.ecr.aws/lambda/provided:al2023 AS builder
1+
FROM lambda-shell-runtime:base AS tiny
22

3-
ARG HTTP_CLI_VERSION=v1.0.1
4-
5-
RUN dnf install -y unzip && \
6-
dnf clean all
7-
8-
# Download http-cli
9-
RUN --mount=type=secret,id=github_token \
10-
curl -H "Authorization: token $(cat /run/secrets/github_token)" \
11-
-L "https://github.com/ql4b/http-cli/archive/refs/tags/${HTTP_CLI_VERSION}.zip" \
12-
-o http-cli.zip && \
13-
unzip http-cli.zip && \
14-
mkdir -p /http-cli-bin && \
15-
mv http-cli-${HTTP_CLI_VERSION#v}/http-cli /http-cli-bin/ && \
16-
chmod +x /http-cli-bin/http-cli && \
17-
rm -rf http-cli.zip http-cli-${HTTP_CLI_VERSION#v}
18-
19-
# Stage 2: Runtime stage
20-
FROM public.ecr.aws/lambda/provided:al2023
21-
22-
# Install only runtime dependencies
23-
RUN dnf install -y jq && \
24-
dnf clean all && \
25-
rm -rf /var/cache/dnf
26-
27-
# Copy http-cli
28-
COPY --from=builder /http-cli-bin/http-cli /var/task/bin/http-cli
29-
ENV PATH="/var/task/bin:${PATH}"
30-
31-
COPY runtime/bootstrap /var/runtime/bootstrap
32-
RUN chmod +x /var/runtime/bootstrap
33-
34-
WORKDIR /var/task
35-
36-
COPY task/handler.sh handler.sh
373
COPY task/helpers.sh helpers.sh
4+
5+
LABEL org.opencontainers.image.title="lambda-shell-runtime:tiny"

0 commit comments

Comments
 (0)