-
Notifications
You must be signed in to change notification settings - Fork 6
81 lines (67 loc) · 2.7 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: docker
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
jobs:
build-docker-single-arch:
name: build-docker-${{ matrix.cpu_arch }}
runs-on: ubuntu-22.04
strategy:
matrix:
cpu_arch: [aarch64, x86_64]
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Cross build binaries
run: |
cargo install cross
make build-${{ matrix.cpu_arch }}
- name: Make bin dir
run: mkdir ./bin
- name: Move cross-built binary into Docker scope
run: mv ./target/${{ matrix.cpu_arch }}-unknown-linux-gnu/release/eleel ./bin
- name: Map aarch64 to arm64 short arch
if: startsWith(matrix.cpu_arch, 'aarch64')
run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV
- name: Map x86_64 to amd64 short arch
if: startsWith(matrix.cpu_arch, 'x86_64')
run: echo "SHORT_ARCH=amd64" >> $GITHUB_ENV
- name: Install QEMU
run: sudo apt-get update && sudo apt-get install -y qemu-user-static
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
file: ./Dockerfile.cross
context: .
platforms: linux/${{ env.SHORT_ARCH }}
push: true
tags: |
${{ github.repository_owner }}/eleel:latest-${{ env.SHORT_ARCH }}
build-docker-multiarch:
name: build-docker-eleel-multiarch
runs-on: ubuntu-22.04
needs: [build-docker-single-arch]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Create and push multiarch manifests
run: |
docker buildx imagetools create -t ${{ github.repository_owner}}/eleel:latest \
${{ github.repository_owner}}/eleel:latest-arm64 \
${{ github.repository_owner}}/eleel:latest-amd64;