-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-push.sh
46 lines (38 loc) · 1.33 KB
/
docker-push.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# =======================================================================================
# Push Docker image
#
# This scripts pushes the Docker image
# =======================================================================================
# ------------------------------------------------------
# Import parameters
source param.sh
# ------------------------------------------------------
# Functions
# Launch the docker tag command from arguments
launchDockerTag() {
local TAG_SUFFIX="$1"
for TAG_VERSION in "${TAG_VERSIONS[@]}"
do
echo "Tag image ${IMAGE_NAME}:${TAG_VERSION}${TAG_SUFFIX} to custom registry ${DOCKER_REGISTRY}/${IMAGE_NAME}"
docker tag ${IMAGE_NAME}:${TAG_VERSION}${TAG_SUFFIX} ${DOCKER_REGISTRY}/${IMAGE_NAME}:${TAG_VERSION}${TAG_SUFFIX}
done
}
# Launch the docker push command
launchDockerPush() {
echo "Push images with all tags to custom registry: ${DOCKER_REGISTRY}/${IMAGE_NAME}"
docker push --all-tags ${DOCKER_REGISTRY}/${IMAGE_NAME}
}
# ------------------------------------------------------
# Commands
if [[ ${TAG_SUFFIXES[@]} ]]; then
# Targets / tags suffixes
for TARGET in "${!TAG_SUFFIXES[@]}"
do
launchDockerTag "${TAG_SEPARATOR}${TAG_SUFFIXES[$TARGET]}"
done
else
# No target / no tag suffix
launchDockerTag ""
fi
launchDockerPush