-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·28 lines (21 loc) · 905 Bytes
/
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
#!/bin/bash
set -eEuo pipefail
export DOCKER_BUILDKIT=1
declare -r VERSION_PYTHON=$1
declare -r VERSION_TESTINFRA=$2
declare VERSION_PYTHON_NUMERIC
VERSION_PYTHON_NUMERIC=$(echo "${VERSION_PYTHON}" | tr -dc '0-9')
declare -r IMAGE_TAG_BASE="renatomefi/docker-testinfra"
declare -r IMAGE_TAG="${IMAGE_TAG_BASE}:${VERSION_TESTINFRA}-${VERSION_PYTHON}"
sed -E "/pip./ s/ testinfra/ testinfra==${VERSION_TESTINFRA}/g" "Dockerfile-${VERSION_PYTHON}" | \
docker build --pull -t "${IMAGE_TAG}" -f - .
## safety check
docker run --rm -t "${IMAGE_TAG}" --version | \
grep -q "testinfra-${VERSION_TESTINFRA}"
docker run --rm -t --entrypoint="${VERSION_PYTHON}" "${IMAGE_TAG}" --version | \
grep -q "Python ${VERSION_PYTHON_NUMERIC}"
for TAG_EXTRA in "${@:3}"
do
docker tag "${IMAGE_TAG}" "${IMAGE_TAG_BASE}:${TAG_EXTRA}" \
&& echo "${IMAGE_TAG_BASE}:${TAG_EXTRA}" >> ./tmp/tags.list
done