Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6bbc649
docs: add minimal description to the README.md
skunxicat Jul 4, 2025
2ba1eec
feat: initial release of Lambda Shell Runtime base images
skunxicat Jul 8, 2025
416e244
chore: run semantic release on develop branch
skunxicat Jul 9, 2025
2ee3dc1
ci: set develop as prelease branch
skunxicat Jul 9, 2025
520bcf2
feat: trigger prerelease for lambda-shell-runtime
skunxicat Jul 9, 2025
150c585
chore: make publish script executable
skunxicat Jul 9, 2025
0fe7502
feat: trigger pre-release v0.1.1
skunxicat Jul 9, 2025
fd860ae
fix: correct Docker tag format in publish script
skunxicat Jul 9, 2025
2a17c10
chore(ci): build Docker images before semantic-release
skunxicat Jul 9, 2025
51db3f7
feat: trigger pre-release v0.1.1
skunxicat Jul 9, 2025
5c50562
fix: fix base image names and tags
skunxicat Jul 9, 2025
8a10828
fix(ci): update workflow to support develop branch
skunxicat Jul 9, 2025
53e289e
feat(ci): enable multi-arch Docker builds for amd64 and arm64
skunxicat Jul 9, 2025
b297a9d
fix(docker): use ARM architecture for AWS CLI v2 install
skunxicat Jul 9, 2025
e05d285
fix(docker): use ARM architecture for AWS CLI v2 install
skunxicat Jul 9, 2025
52f1af6
fix: fix local builds
skunxicat Jul 9, 2025
a3767bb
feat: add --tag flag option for build
skunxicat Jul 9, 2025
4335d83
fix: add /var/task/bin to PATH in full variant Dockerfile
skunxicat Jul 9, 2025
767e963
fix(ci): build and load Docker images for arm64 using buildx
skunxicat Jul 9, 2025
08db91c
feat: micro runtime image uses awscurl instead of aws-cli
skunxicat Jul 9, 2025
c71c122
chore: add examples
skunxicat Jul 9, 2025
9ea3f18
feat: add new real life example and refactor repository layout
skunxicat Jul 10, 2025
53a49a7
chore: fix FROM statment in examples Dockerfile
skunxicat Jul 10, 2025
ca1bd8e
feat: updated examples functions
skunxicat Jul 11, 2025
fe7464d
feat: update publish script
skunxicat Jul 11, 2025
e4587e7
feat: update publish script
skunxicat Jul 11, 2025
fdd34f8
feat: full variant uses aws-cli installation as dnf package
skunxicat Jul 12, 2025
bffba7b
docs: update README.md
skunxicat Jul 12, 2025
0c6f188
ci: add docker caching layer
skunxicat Jul 12, 2025
a845f39
ci: enable docker layer caching using buildx builder
skunxicat Jul 12, 2025
0b3cdfd
feat: add HTTP_CLI_VERSION build ARG and set default into the github …
skunxicat Jul 26, 2025
a8eaa8e
fix: fix how the unzipped http-cli content is handled during build (#5)
skunxicat Jul 26, 2025
ad036fd
feat: make helpers function available in the LAMBDA_TASK_ROOT folder …
skunxicat Jul 26, 2025
84a85a9
chore: removed examples
skunxicat Jul 27, 2025
ceb6279
chore(ci): add base image build step to release workflow
skunxicat Jul 27, 2025
dde782d
build: use a single Dockerfile for all targets
skunxicat Jul 27, 2025
a217fb6
feat: add base image build step to release workflow
skunxicat Jul 27, 2025
62ee31a
fix: fix workflow using target in the build commands
skunxicat Jul 27, 2025
5a540e6
fix: fix how to pass the GITHUB tocken as secret
skunxicat Jul 27, 2025
8baaab4
fix: fix how to pass the GITHUB tocken as secret
skunxicat Jul 27, 2025
650fcea
fix: fix the mess with VERSION and HTTP_CLI_VERSION
skunxicat Jul 27, 2025
12c2b66
fix: fix the mess with VERSION and HTTP_CLI_VERSION
skunxicat Jul 27, 2025
d381ad6
feat: fix workflow
skunxicat Jul 27, 2025
1b86371
refactor: refactor the build process
skunxicat Jul 27, 2025
1d25279
fix: fix logging to ghcr step
skunxicat Jul 27, 2025
4177949
chore: cleanup unused flows
skunxicat Jul 27, 2025
91efb65
chore: cleanup unused flows
skunxicat Jul 27, 2025
61c0c8b
refactor: remove bottlenck on slow builders
skunxicat Jul 27, 2025
53226a9
feat: add concurrency control to workflows
skunxicat Jul 27, 2025
dc83c0c
feat: add concurrency control to workflows
skunxicat Jul 27, 2025
a77b46e
fix: fix authentication issues
skunxicat Jul 27, 2025
51d618f
fix: remove authentication for downloading http-cli
skunxicat Jul 27, 2025
a163bfd
fix: add permission to the build-base workflow
skunxicat Jul 27, 2025
8c7f073
ci: add permission to build-base workflow
skunxicat Jul 27, 2025
9198d12
docs: update README.md
skunxicat Jul 28, 2025
36976c8
fix: fix awscli installation in the full variant
skunxicat Jul 28, 2025
068e24a
docs: update README
skunxicat Jul 28, 2025
7568524
fix: fix micro and full image hierarchy
skunxicat Jul 28, 2025
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
117 changes: 117 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build and Release

on:
push:
branches:
- develop
- main
pull_request:
branches:
- main

permissions:
contents: write
issues: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-base:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and push base
run: |
echo "${{ secrets.GHCR_PAT }}" > github_token
docker buildx build \
--platform linux/arm64 \
--provenance=false \
--secret id=github_token,src=github_token \
--target base \
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:base \
--push \
.
env:
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }}

build:
needs: build-base
runs-on: ubuntu-latest
env:
HTTP_CLI_VERSION: v1.0.1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create and use buildx builder
run: |
docker buildx create --name shell-runtime-builder --driver docker-container --use
docker buildx inspect shell-runtime-builder --bootstrap
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set version
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
# Get semantic version for main branch
VERSION=$(npx semantic-release --no-ci --dry-run --branch main 2>&1 | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+' || echo "")
if [ -z "$VERSION" ]; then
echo "No release needed"
echo "VERSION=develop" >> $GITHUB_ENV
echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
else
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "SHOULD_RELEASE=true" >> $GITHUB_ENV
fi
else
# Use branch name for develop
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
fi
echo "Detected VERSION: $VERSION"
- name: Log in to GHCR
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u skunxicat --password-stdin
- name: Build and push images
run: |
echo "${{ secrets.GHCR_PAT }}" > github_token
export GITHUB_TOKEN="${{ secrets.GHCR_PAT }}"

# Build and push all variants
make push VERSION="$VERSION" REGISTRY="ghcr.io/${{ github.repository_owner }}"
shell: bash
- name: Create release
if: env.SHOULD_RELEASE == 'true'
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_PAT: ${{ secrets.GHCR_PAT }}
56 changes: 56 additions & 0 deletions .github/workflows/build-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Base Image

on:
push:
branches: [ main, develop ]
paths:
- 'Dockerfile'
- 'runtime/**'
- 'task/handler.sh'
- '.github/workflows/build-base.yml'
pull_request:
branches: [ main ]
paths:
- 'Dockerfile'
- 'runtime/**'
- 'task/handler.sh'

permissions:
contents: write
issues: write
pull-requests: write
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-base:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}

- name: Build and push base
run: |
echo "${{ secrets.GHCR_PAT }}" > github_token
docker buildx build \
--platform linux/arm64 \
--provenance=false \
--secret id=github_token,src=github_token \
--target base \
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:base \
--push \
.
env:
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }}
62 changes: 62 additions & 0 deletions .github/workflows/build-installers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Installers

on:
push:
branches: [ main, develop ]
paths:
- 'Dockerfile'
- '.github/workflows/build-installers.yml'
pull_request:
branches: [ main ]
paths:
- 'Dockerfile'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-installers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}

- name: Build and push installers
run: |
# Build awscurl-installer
docker buildx build \
--platform linux/arm64 \
--provenance=false \
--target awscurl-installer \
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:awscurl-installer \
--push \
-f - . << 'EOF'
FROM public.ecr.aws/lambda/provided:al2023 AS awscurl-installer
RUN dnf install -y unzip python3-pip findutils && dnf clean all
RUN pip3 install --no-cache-dir --target /tmp/awscurl awscurl && \
find /tmp/awscurl -type d -name '__pycache__' -exec rm -rf {} + && \
find /tmp/awscurl -type f -name '*.pyc' -delete && \
find /tmp/awscurl -type d -name '*.dist-info' -exec rm -rf {} +
EOF

# Build awscli-installer
docker buildx build \
--platform linux/arm64 \
--provenance=false \
--target awscli-installer \
--tag ghcr.io/${{ github.repository_owner }}/lambda-shell-runtime:awscli-installer \
--push \
-f - . << 'EOF'
FROM public.ecr.aws/lambda/provided:al2023 AS awscli-installer
RUN dnf install -y aws-cli && dnf clean all
EOF
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Docker artifacts
*.tar
*.tar.gz
*.tar.xz
*.tgz
*.img

# Build output
.DS_Store
build/
dist/
*.log
node_modules/

# VSCode settings
.vscode/
#examples/
95 changes: 95 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
FROM public.ecr.aws/lambda/provided:al2023 AS builder

ARG HTTP_CLI_VERSION=v1.0.1

RUN dnf install -y unzip && \
dnf clean all

# Download http-cli
RUN curl \
-L "https://github.com/ql4b/http-cli/archive/refs/tags/${HTTP_CLI_VERSION}.zip" \
-o http-cli.zip && \
unzip http-cli.zip && \
mkdir -p /http-cli-bin && \
mv http-cli-${HTTP_CLI_VERSION#v}/http-cli /http-cli-bin/ && \
chmod +x /http-cli-bin/http-cli && \
rm -rf http-cli.zip http-cli-${HTTP_CLI_VERSION#v}

LABEL org.opencontainers.image.http_cli_version="${HTTP_CLI_VERSION}"

# base: minimal runtime setup with jq
FROM public.ecr.aws/lambda/provided:al2023 AS base

ARG VERSION=develop
ARG HTTP_CLI_VERSION

# Install only runtime dependencies
RUN dnf install -y jq && \
dnf clean all && \
rm -rf /var/cache/dnf

# Copy http-cli
COPY --from=builder /http-cli-bin/http-cli /var/task/bin/http-cli
ENV PATH="/var/task/bin:${PATH}"

COPY runtime/bootstrap /var/runtime/bootstrap
RUN chmod +x /var/runtime/bootstrap

WORKDIR /var/task

COPY task/handler.sh handler.sh

LABEL org.opencontainers.image.source="https://github.com/ql4b/lambda-shell-runtime"
LABEL org.opencontainers.image.version="${VERSION}"

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

ARG VERSION
ARG HTTP_CLI_VERSION

COPY task/helpers.sh helpers.sh

LABEL org.opencontainers.image.title="lambda-shell-runtime:tiny"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.http_cli_version="${HTTP_CLI_VERSION}"

# micro: includes awscurl
FROM tiny AS micro

ARG VERSION
ARG HTTP_CLI_VERSION

RUN dnf install -y python3 && \
dnf clean all && \
rm -rf /var/cache/dnf

COPY --from=ghcr.io/ql4b/lambda-shell-runtime:awscurl-installer /tmp/awscurl /var/task/aws
RUN rm -rf \
/var/task/aws/__pycache__ \
/var/task/aws/*.dist-info \
/var/task/aws/**/__pycache__

ENV PYTHONPATH="/var/task/aws"

RUN mkdir -p /var/task/bin && \
printf '#!/bin/sh\nexport PYTHONPATH=/var/task/aws\nexec python3 -m awscurl.awscurl "$@"\n' > /var/task/bin/awscurl && \
chmod +x /var/task/bin/awscurl

LABEL org.opencontainers.image.title="lambda-shell-runtime:micro"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.http_cli_version="${HTTP_CLI_VERSION}"

# full: includes aws-cli for complete AWS functionality
FROM tiny AS full

ARG VERSION
ARG HTTP_CLI_VERSION

RUN dnf install -y awscli-2 && \
dnf clean all && \
rm -rf /var/cache/dnf

LABEL org.opencontainers.image.title="lambda-shell-runtime:full"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.http_cli_version="${HTTP_CLI_VERSION}"
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: help build push clean base tiny micro full

PLATFORM ?= linux/arm64
TAG ?= lambda-shell-runtime
VERSION ?= develop
REGISTRY ?= ghcr.io/ql4b

help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

build: tiny micro full ## Build all variants locally

base: ## Build base image
VERSION=$(VERSION) ./build --platform $(PLATFORM) --tag $(TAG) --load base

tiny: base ## Build tiny variant
VERSION=$(VERSION) ./build --platform $(PLATFORM) --tag $(TAG) --load tiny

micro: base ## Build micro variant
VERSION=$(VERSION) ./build --platform $(PLATFORM) --tag $(TAG) --load micro

full: base ## Build full variant
VERSION=$(VERSION) ./build --platform $(PLATFORM) --tag $(TAG) --load full

push-base: ## Push base to registry
VERSION=$(VERSION) ./build --platform $(PLATFORM) --tag $(REGISTRY)/$(TAG) --push base

push: ## Push all variants to registry
VERSION=$(VERSION) ./build --platform $(PLATFORM) --tag $(REGISTRY)/$(TAG) --push tiny micro full

clean: ## Remove local images
docker rmi -f $(TAG):base $(TAG):tiny $(TAG):micro $(TAG):full 2>/dev/null || true
Loading