forked from portainer/kubesolo
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (93 loc) · 3.39 KB
/
build-pause-image.yaml
File metadata and controls
107 lines (93 loc) · 3.39 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: pause-image
on:
workflow_dispatch:
env:
REGISTRY: docker.io
IMAGE_NAME: portainer/pause
jobs:
build-pause:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goarch: amd64
gcc: x86_64-linux-gnu-gcc
- goarch: arm64
gcc: aarch64-linux-gnu-gcc
- goarch: arm
gcc: arm-linux-gnueabihf-gcc
- goarch: riscv64
gcc: riscv64-linux-gnu-gcc
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Fetch Kubernetes pause source
run: |
mkdir -p /tmp/k8s-pause
cd /tmp/k8s-pause
git init
git remote add origin https://github.com/kubernetes/kubernetes.git
git config core.sparseCheckout true
echo "build/pause/*" > .git/info/sparse-checkout
git pull --depth=1 origin master
cp -r build/pause ${{ github.workspace }}/pause-build
- name: Install cross-compilers
run: sudo make install-cross-compilers
- name: Build pause binary
run: |
cd ${{ github.workspace }}/pause-build
mkdir -p bin
${{ matrix.gcc }} -Os -Wall -Werror -static -DVERSION=latest \
-o bin/pause-linux-${{ matrix.goarch }} linux/pause.c
# Strip binary to reduce size
case "${{ matrix.goarch }}" in
amd64) x86_64-linux-gnu-strip bin/pause-linux-${{ matrix.goarch }} ;;
arm64) aarch64-linux-gnu-strip bin/pause-linux-${{ matrix.goarch }} ;;
arm) arm-linux-gnueabihf-strip bin/pause-linux-${{ matrix.goarch }} ;;
riscv64) riscv64-linux-gnu-strip bin/pause-linux-${{ matrix.goarch }} ;;
esac
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push image
uses: docker/build-push-action@v6.7.0
with:
context: ./pause-build
platforms: linux/${{ matrix.goarch }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:linux-${{ matrix.goarch }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=registry
build-args: |
BASE=scratch
ARCH=${{ matrix.goarch }}
create-manifest:
needs: build-pause
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Create and push multi-arch manifest
run: |
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:linux-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:linux-arm64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:linux-arm \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:linux-riscv64
docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest