Skip to content

Commit

Permalink
Tag and push Prometheus Exporter file Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomefi committed Apr 16, 2019
1 parent 4619408 commit 0a570b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ version: 2.1
- build-fpm
- build-cli
- test-http-e2e: *test-http
- test-prometheus-exporter-file-e2e: &test-prometheus-exporter-file-e2e
requires:
- build-prometheus-exporter-file
- test-fpm: &test-fpm
requires:
- build-http
Expand Down Expand Up @@ -49,7 +52,9 @@ version: 2.1
- test-fpm
- test-http
- test-http-e2e
- test-prometheus-exporter-file-e2e
- scan-vulnerability
- push-prometheus-exporter-file: *push-context
- push-fpm: *push-context
- push-cli: *push-context

Expand All @@ -62,6 +67,7 @@ version: 2.1
- build-cli: *build-cli
- test-http: *test-http
- test-http-e2e: *test-http
- test-prometheus-exporter-file-e2e: *test-prometheus-exporter-file-e2e
- test-fpm: *test-fpm
- test-cli: *test-cli
- scan-vulnerability: *scan-vulnerability
Expand All @@ -75,6 +81,7 @@ version: 2.1
- test-cli
- test-fpm
- test-http
- test-prometheus-exporter-file-e2e
- push-http: &push-context-approval
context: dockerhub
filters:
Expand All @@ -83,6 +90,7 @@ version: 2.1
- master
requires:
- push-approval
- push-prometheus-exporter-file: *push-context-approval
- push-fpm: *push-context-approval
- push-cli: *push-context-approval

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-http: clean-tags
# Adding arbitrary version 1.0 in order to make sure if we break compatibility we have to up it
build-prometheus-exporter-file: BUILDINGIMAGE=prometheus-exporter-file
build-prometheus-exporter-file: clean-tags
./build-prometheus-exporter-file.sh 1.15 prometheus-exporter-file1.0
./build-prometheus-exporter-file.sh 1.15 prometheus-exporter-file1.0 prometheus-exporter-file1

.NOTPARALLEL: clean-tags
clean-tags:
Expand Down
11 changes: 5 additions & 6 deletions build-prometheus-exporter-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ declare -r DOCKER_FILE="http"

declare -r VERSION_NGINX=$1

declare -r IMAGE_EXTRA_TAG=${2:-}

# 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
Expand All @@ -18,14 +16,15 @@ declare -r IMAGE_ORIGINAL_TAG="nginx:1.[0-9][0-9]?-alpine"
declare -r IMAGE_TAG="nginx:${VERSION_NGINX}-alpine"
declare -r USABILLA_TAG_PREFIX="usabillabv/php"
declare -r USABILLA_TAG="${USABILLA_TAG_PREFIX}:${IMAGE}"
declare -r USABILLA_EXTRA_TAG="${USABILLA_TAG_PREFIX}:${IMAGE_EXTRA_TAG}"

TAG_FILE="./tmp/build-${IMAGE}.tags"

sed -E "s/${IMAGE_ORIGINAL_TAG}/${IMAGE_TAG}/g" "Dockerfile-${DOCKER_FILE}" | docker build --pull -t "${USABILLA_TAG}" \
--build-arg=NGINX_VHOST_TEMPLATE=prometheus-exporter-file --target="http" -f - . \
&& echo "${USABILLA_TAG}" >> "${TAG_FILE}"

if [[ -n ${IMAGE_EXTRA_TAG} ]]; then
docker tag "${USABILLA_TAG}" "${USABILLA_EXTRA_TAG}" && echo "${USABILLA_EXTRA_TAG}" >> "${TAG_FILE}"
fi
for USABILLA_TAG_EXTRA in "${@:2}"
do
docker tag "${USABILLA_TAG}" "${USABILLA_TAG_PREFIX}:${USABILLA_TAG_EXTRA}" \
&& echo "${USABILLA_TAG_PREFIX}:${USABILLA_TAG_EXTRA}" >> "${TAG_FILE}"
done

0 comments on commit 0a570b6

Please sign in to comment.