Skip to content

Commit

Permalink
build the docker images in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
glehmann committed Feb 5, 2024
1 parent e2ffff3 commit d5d557f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: docker

# Only do the release on x.y.z tags.
on:
push:
branches:
- main
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
docker:
name: docker
runs-on: ubuntu-latest
env:
CROSS_VERSION: v0.2.5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Use Cross
shell: bash
run: |
# In the past, new releases of 'cross' have broken CI. So for now, we
# pin it. We also use their pre-compiled binary releases because cross
# has over 100 dependencies and takes a bit to compile.
dir="$RUNNER_TEMP/cross-download"
mkdir "$dir"
echo "$dir" >> $GITHUB_PATH
cd "$dir"
curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"
tar xf cross-x86_64-unknown-linux-musl.tar.gz
echo "CARGO=cross" >> $GITHUB_ENV
- name: Install earthly
uses: earthly/actions-setup@v1.0.4
with:
version: 0.8.3
use-cache: "false"

- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push the images
run: earthly --push --no-output +docker-multiplatform --build=cross --tag=${{ github.ref_name }}
11 changes: 7 additions & 4 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ cross:
LOCALLY
ARG --required platform_slug
ARG --required target
RUN cross build --target $target --release \
RUN rm -rf target/release \
&& cross build --target $target --release \
&& mkdir -p bin \
&& cp target/$target/release/yage bin/yage-$platform_slug

cross-dind:
Expand Down Expand Up @@ -78,8 +80,9 @@ docker:
ARG build=earthly
COPY (+artifact/yage --build=$build) /yage
ENTRYPOINT ["/yage"]
ARG tag=latest
SAVE IMAGE --push glehmann/yage:$tag
ARG tag=main
# SAVE IMAGE --push glehmann/yage:$tag
SAVE IMAGE --push ghcr.io/glehmann/yage:$tag

docker-multiplatform:
ARG build=earthly
Expand All @@ -90,5 +93,5 @@ docker-multiplatform:
--platform=linux/arm/v7 \
--platform=linux/arm/v6 \
--platform=linux/ppc64le \
--platform=linux/s390x \
# --platform=linux/s390x \
+docker --build=$build

0 comments on commit d5d557f

Please sign in to comment.