This repository has been archived by the owner on Dec 13, 2024. It is now read-only.
forked from themgt/k3os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·58 lines (46 loc) · 1.78 KB
/
build.sh
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
#!/bin/sh
set -ex
# Check if binfmt arm64 is enabled
if [ ! -f /proc/sys/fs/binfmt_misc/qemu-aarch64 ]; then
sudo podman run --rm --privileged alekitto/qemu-user-static --reset -p yes
fi
# Remove unix:// from DOCKER_HOST
DOCKER_HOST=$(echo ${DOCKER_HOST} | sed 's/^unix:\/\///')
GIT_TAG=$(git describe --tags --abbrev=0)
rm -rf ./build/
podman run --rm -it \
-v "$(pwd):/work" \
--privileged \
--arch amd64 \
-e BUILDPLATFORM=linux/amd64 \
-e ARCH=amd64 \
-v "${DOCKER_HOST}:/var/run/docker.sock" \
ghcr.io/darkness4/k3os:latest-base
podman tag ghcr.io/darkness4/k3os:latest "ghcr.io/darkness4/k3os:latest-amd64"
podman tag ghcr.io/darkness4/k3os:latest "ghcr.io/darkness4/k3os:${GIT_TAG}-amd64"
podman push "ghcr.io/darkness4/k3os:${GIT_TAG}-amd64"
podman push "ghcr.io/darkness4/k3os:latest-amd64"
# shellcheck disable=SC2046
podman rmi -f $(podman images --filter=reference="ghcr.io/darkness4/k3os*:dev" -q) || true
rm -rf ./build/
podman run --rm -it \
-v "$(pwd):/work" \
--privileged \
--arch arm64 \
--variant v8 \
-e BUILDPLATFORM=linux/arm64/v8 \
-e ARCH=arm64 \
-e GOOS=linux \
-e GOARCH=arm64 \
-v "${DOCKER_HOST}:/var/run/docker.sock" \
ghcr.io/darkness4/k3os:latest-base
podman tag ghcr.io/darkness4/k3os:latest ghcr.io/darkness4/k3os:latest-arm64
podman tag ghcr.io/darkness4/k3os:latest "ghcr.io/darkness4/k3os:${GIT_TAG}-arm64"
podman push "ghcr.io/darkness4/k3os:${GIT_TAG}-arm64"
podman push "ghcr.io/darkness4/k3os:latest-arm64"
# Build the manifest
podman manifest rm ghcr.io/darkness4/k3os:${GIT_TAG} || true
podman manifest create ghcr.io/darkness4/k3os:${GIT_TAG} \
ghcr.io/darkness4/k3os:${GIT_TAG}-amd64 \
ghcr.io/darkness4/k3os:${GIT_TAG}-arm64
podman manifest push --all ghcr.io/darkness4/k3os:${GIT_TAG} docker://ghcr.io/darkness4/k3os:${GIT_TAG}