-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun
More file actions
executable file
·53 lines (45 loc) · 1.52 KB
/
Copy pathrun
File metadata and controls
executable file
·53 lines (45 loc) · 1.52 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
#!/bin/bash
set -eu -o pipefail
CONTAINER_NAME=toolbox
IMAGE_NAME=timjdfletcher/${CONTAINER_NAME}
IMAGE_TAG=tmp
PLATFORMS="linux/amd64,linux/arm64"
TOOLS="ca-certificates curl dnsutils jq less lsof mmc-utils net-tools procps strace tcpdump vim"
build () {
_buildx_setup
docker buildx build --load --tag "${IMAGE_NAME}:${IMAGE_TAG}" --build-arg TOOLS="${TOOLS}" --file Dockerfile .
docker tag "${IMAGE_NAME}:${IMAGE_TAG}" "${IMAGE_NAME}:latest"
}
clean () {
docker image rm "${IMAGE_NAME}:${IMAGE_TAG}" || true
docker image rm "${IMAGE_NAME}:latest" || true
docker buildx prune --force
docker buildx rm builder || true
}
usage() {
echo "./run build - Build a local image called ${IMAGE_NAME}:${IMAGE_TAG}"
echo "./run release - Tests and then releases to dockerhub a multiarch version of the latest tag"
}
find_release(){
TAG="$(git tag | grep ^${CONTAINER_NAME} | sort -n | tail -n 1)"
git checkout "${TAG}"
export IMAGE_TAG=$TAG
}
_buildx_setup () {
docker buildx use builder || docker buildx create --name builder
docker buildx inspect --bootstrap
}
release() {
find_release
_buildx_setup
docker buildx build --platform "${PLATFORMS}" --tag "${IMAGE_NAME}:${IMAGE_TAG}" --build-arg TOOLS="${TOOLS}" --push --file Dockerfile .
docker buildx build --platform "${PLATFORMS}" --tag "${IMAGE_NAME}:latest" --build-arg TOOLS="${TOOLS}" --push --file Dockerfile .
}
CMD=${1:-}
shift || true
case ${CMD} in
build) build ;;
clean) clean ;;
release) find_release && clean && release ;;
*) usage ;;
esac