-
Notifications
You must be signed in to change notification settings - Fork 32
/
dockerized
executable file
·28 lines (21 loc) · 1.01 KB
/
dockerized
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
#!/bin/bash
set -euxo pipefail
# Reuse image when building the same revision
IMAGE_NAME=${IMAGE_NAME:-distributions}
IMAGE_TAG="$(git rev-parse --short HEAD)"
# './dockerized ... clean' should also remove any prebuilt images
if [[ "${@:$#}" == "clean" ]]; then
docker image rmi "$IMAGE_NAME:$IMAGE_TAG" 2> /dev/null || true
fi
if [[ "$(docker images -q "$IMAGE_NAME:$IMAGE_TAG" 2> /dev/null)" == "" ]]; then
# We always want the latest base image
docker pull ubuntu:20.04
# Build image
docker build . -t "$IMAGE_NAME:$IMAGE_TAG" \
--build-arg CACHEBUST="$IMAGE_TAG" \
--build-arg USER_UID="$(id -u "$USER")" \
--build-arg KUBO_VER="${KUBO_VER:-$(curl -s https://dist.ipfs.tech/kubo/versions | tail -n 1)}" # match http api client version on CI
fi
# We use host networking as the build process assumes a fairly long-lived ipfs
# node has the CIDs (we give them to the collab cluster to pin)
docker run --rm -i --network host -e DIST_ROOT -v "$(pwd)":/build "$IMAGE_NAME:$IMAGE_TAG" "$@"