Skip to content

Commit

Permalink
Use native ARM builders for container builds
Browse files Browse the repository at this point in the history
This commit replaces #1088 and attempts to build a lading multi-platform
image by use of organization provided ARM native builders. Unsure if this'll
work but I figure it's worth a shot.

Signed-off-by: Brian L. Troutwine <[email protected]>
  • Loading branch information
blt committed Nov 6, 2024
1 parent d8739c2 commit 68f3b2c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
60 changes: 54 additions & 6 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
container:
runs-on: ubuntu-20.04
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-20.04
- arch: arm64
runner: arm-4core-linux-ubuntu24.04
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -47,9 +54,50 @@ jobs:
with:
file: Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/${{ matrix.arch }}
tags: |
${{ steps.meta.outputs.tags }}
${{ steps.meta.outputs.tags }}-${{ matrix.arch }}
push: true
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}
cache-from: type=registry,ref=ghcr.io/datadog/lading:latest
cache-to: type=registry,ref=ghcr.io/datadog/lading:latest,mode=max

manifest:
name: Create Multi-Arch Manifest
needs: build
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- name: Log in to Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Extract Docker Metadata
uses: docker/[email protected]
id: meta
with:
tags: |
type=sha,format=long
type=ref,prefix=pr-,event=pr
type=semver,pattern={{version}},event=tag
type=semver,pattern={{major}}.{{minor}},event=tag
type=semver,pattern={{major}},event=tag
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Create and Push Multi-Arch Manifest
run: |
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}-arm64
docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update the rust version in-sync with the version in rust-toolchain.toml
FROM docker.io/rust:1.81.0-bullseye AS builder
FROM --platform=$BUILDPLATFORM docker.io/rust:1.81.0-bullseye AS builder

RUN apt-get update && apt-get install -y \
protobuf-compiler fuse3 libfuse3-dev \
Expand All @@ -9,7 +9,7 @@ WORKDIR /app
COPY . /app
RUN cargo build --release --locked --bin lading

FROM docker.io/debian:bullseye-20240701-slim
FROM --platform=$BUILDPLATFORM docker.io/debian:bullseye-20240701-slim
RUN apt-get update && apt-get install -y libfuse3-dev=3.10.3-2 fuse3=3.10.3-2 && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/lading /usr/bin/lading

Expand Down

0 comments on commit 68f3b2c

Please sign in to comment.