-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-prometheus-exporter-file.sh
31 lines (21 loc) · 1.07 KB
/
build-prometheus-exporter-file.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
#!/bin/bash
set -eEuo pipefail
export DOCKER_BUILDKIT=1
declare -r IMAGE="prometheus-exporter-file"
declare -r DOCKER_FILE="nginx"
declare -r VERSION_NGINX=$1
# I could create a placeholder like nginx:x.y-alpine in the Dockerfile itself,
# but I think it wouldn't be a good experience if you try to build the image yourself
# thus that's the way I opted to have dynamic base images
declare -r IMAGE_ORIGINAL_TAG="nginx:1.[0-9][0-9]?-alpine"
declare -r IMAGE_TAG="nginx:${VERSION_NGINX}-alpine"
declare -r TOKEN27_TAG_PREFIX="token27/nginx"
declare -r TOKEN27_TAG="${TOKEN27_TAG_PREFIX}:${IMAGE}"
TAG_FILE="./tmp/build-${IMAGE}.tags"
sed -E "s/${IMAGE_ORIGINAL_TAG}/${IMAGE_TAG}/g" "./docker/${DOCKER_FILE}.Dockerfile" | docker build --pull -t "${TOKEN27_TAG}" \
--build-arg=NGINX_VHOST_TEMPLATE=prometheus-exporter-file --target="http-dev" -f - . &&
echo "${TOKEN27_TAG}" >>"${TAG_FILE}"
for TOKEN27_TAG_EXTRA in "${@:2}"; do
docker tag "${TOKEN27_TAG}" "${TOKEN27_TAG_PREFIX}:${TOKEN27_TAG_EXTRA}" &&
echo "${TOKEN27_TAG_PREFIX}:${TOKEN27_TAG_EXTRA}" >>"${TAG_FILE}"
done