-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_multiarch.sh
More file actions
executable file
·66 lines (52 loc) · 1.85 KB
/
create_multiarch.sh
File metadata and controls
executable file
·66 lines (52 loc) · 1.85 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
#!/usr/bin/env bash
## vars
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" # get current script dir portibly
if [[ ${SUDO_USER} ]]; then
REAL_USER="${SUDO_USER}" # or use sudo user
else
REAL_USER="$(id -un)" # fallback to root
fi
REAL_GROUP="$(id -gn ${REAL_USER})" # fallback to real_user group
if [[ ! -f "${SCRIPT_DIR}/.env" ]]; then
echo -ne "E: No env file present! Please create one. See the wiki for details\n"
exit 1
fi
. ${SCRIPT_DIR}/.env
printenv
if [[ "$(docker system info | grep 'io.containerd.snapshotter.v1')" == "" ]]; then
echo "E: Docker must be set to use containerd-snapshotter. Please see https://docs.docker.com/engine/storage/containerd/#enable-containerd-image-store-on-docker-engine"
exit 1
fi
##
##
## bienvenido
echo -ne "I: Welcome!\n"
echo -ne "I: This script will merge the amd64 and arm64v8 docker images of your current branch into one, and push it to ghcr.io\n"
echo -ne "I: Please ensure the docker-buildx plugin is correctly installed, and that your system is authenticated with ghcr.io\n"
##
##
## pull the images
if [[ "$(docker image ls | grep ${KDD_REGISTRY} | grep ${KDD_BRANCH}-amd64)" == "" ]]; then
docker image pull \
--platform linux/amd64 \
${KDD_REGISTRY}:${KDD_BRANCH}-amd64
fi
if [[ "$(docker image ls | grep ${KDD_REGISTRY} | grep ${KDD_BRANCH}-arm64v8)" == "" ]]; then
docker image pull \
--platform linux/arm64/v8 \
${KDD_REGISTRY}:${KDD_BRANCH}-arm64v8
fi
##
##
## build the manifest
docker buildx imagetools create -t ${KDD_REGISTRY}:${KDD_BRANCH} \
${KDD_REGISTRY}:${KDD_BRANCH}-amd64 \
${KDD_REGISTRY}:${KDD_BRANCH}-arm64v8
##
##
## make available locally
docker pull ${KDD_REGISTRY}:${KDD_BRANCH}
echo -ne "I: Remember to delete the old images from your container registry, as they are now clutter\n"
echo -ne "Done!\n"
exit 0