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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
187 changes: 187 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
name: Build and Release Multi-Arch Docker Images

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-amd64:
name: Build AMD64 - Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=python${{ matrix.python-version }}-amd64-latest,enable={{is_default_branch}}
type=ref,event=branch,suffix=-python${{ matrix.python-version }}-amd64
type=ref,event=pr,suffix=-python${{ matrix.python-version }}-amd64
type=semver,pattern={{version}},suffix=-python${{ matrix.python-version }}-amd64
type=semver,pattern={{major}}.{{minor}},suffix=-python${{ matrix.python-version }}-amd64
type=sha,suffix=-python${{ matrix.python-version }}-amd64

- name: Build and push AMD64 image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=amd64-${{ matrix.python-version }}
cache-to: type=gha,mode=max,scope=amd64-${{ matrix.python-version }}

build-arm64:
name: Build ARM64 - Python ${{ matrix.python-version }}
runs-on: ubuntu-24.04-arm64
permissions:
contents: read
packages: write
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=python${{ matrix.python-version }}-arm64-latest,enable={{is_default_branch}}
type=ref,event=branch,suffix=-python${{ matrix.python-version }}-arm64
type=ref,event=pr,suffix=-python${{ matrix.python-version }}-arm64
type=semver,pattern={{version}},suffix=-python${{ matrix.python-version }}-arm64
type=semver,pattern={{major}}.{{minor}},suffix=-python${{ matrix.python-version }}-arm64
type=sha,suffix=-python${{ matrix.python-version }}-arm64

- name: Build and push ARM64 image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=arm64-${{ matrix.python-version }}
cache-to: type=gha,mode=max,scope=arm64-${{ matrix.python-version }}

create-manifest:
name: Create Multi-Arch Manifest - Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest for latest
if: github.ref == 'refs/heads/main'
run: |
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-amd64-latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:python${{ matrix.python-version }}-arm64-latest

- name: Create and push manifest for tags
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/}
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }}-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG_VERSION}-python${{ matrix.python-version }}-arm64

create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [create-manifest]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
body: |
## Multi-Arch Docker Images

Images are available for Python 3.10, 3.11, 3.12, 3.13, and 3.14 on both AMD64 and ARM64 architectures.

### Usage

Pull a specific Python version:
```bash
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python3.14
```

The images support both AMD64 and ARM64 architectures automatically.

### Available Tags
- `${{ github.ref_name }}-python3.10` (multi-arch)
- `${{ github.ref_name }}-python3.11` (multi-arch)
- `${{ github.ref_name }}-python3.12` (multi-arch)
- `${{ github.ref_name }}-python3.13` (multi-arch)
- `${{ github.ref_name }}-python3.14` (multi-arch)
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 4 additions & 35 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Build AWS Lambda deployment packages and layers for multiple Python versions (3.10+) and architectures (x86_64/arm64).

[![Dependabot Updates](https://github.com/fok666/lambda-python-layer/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/fok666/lambda-python-layer/actions/workflows/dependabot/dependabot-updates) [![Build and Release Multi-Arch Docker Images](https://github.com/fok666/lambda-python-layer/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/fok666/lambda-python-layer/actions/workflows/build-and-release.yml)

Inspired by [LambdaZipper](https://github.com/tiivik/LambdaZipper)

## Features

- 🐍 **Multiple Python versions**: Support for Python 3.10, 3.11, 3.12, 3.13, and 3.14 (default)
Expand Down Expand Up @@ -309,41 +313,6 @@ docker run --rm \
lambda-zipper:custom numpy
```

## Migration Guide

### Migrating from Previous Versions

**Old behavior** (required explicit flags):
```bash
./build-multiarch.sh --requirements requirements.txt --python 3.13
```

**New behavior** (smart defaults):
```bash
./build-multiarch.sh # Uses requirements.txt and Python 3.14 by default
```

**Key Changes:**
- Default Python version changed from 3.13 → 3.14
- `-r` or `--requirements` flag now optional (defaults to `requirements.txt`)
- Single combined archive is now the default (use `--individual` for old behavior)
- Both architectures built by default (use `--skip-arm64` or `--skip-x86` to build only one)

### Updating Existing Scripts

If you have scripts using the old syntax, they will continue to work. However, you can simplify them:

```bash
# Old way (still works)
./build-multiarch.sh --requirements requirements.txt --python 3.13

# New simplified way (if using defaults)
./build-multiarch.sh --python 3.13

# Or just use all defaults
./build-multiarch.sh
```

## Output File Naming

Archives are named with the following pattern:
Expand Down
Loading