Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag docker image before pushed to registry #75

Merged
merged 1 commit into from
Nov 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ set -e
usage() {
cat >&2 <<EOF
Usage:
sudo ./build_docker.sh -i=DOCKER_IMAGE_NAME DOCKER_BUILD_DIR [REGISTRY_SERVER REGISTRY_PORT REGISTRY_USERNAME REGISTRY_PASSWD]
sudo ./build_docker.sh [-i DOCKER_IMAGE_NAME] [-t DOCKER_IMAGE_TAG] DOCKER_BUILD_DIR [REGISTRY_SERVER REGISTRY_PORT REGISTRY_USERNAME REGISTRY_PASSWD]

Description:
-i DOCKER_IMAGE_NAME
Specifi the docker images name, by default it is DOCKER_BUILD_DIR
Specify the docker image's name, by default it is DOCKER_BUILD_DIR
-t DOCKER_IMAGE_TAG
Specify the docker image's tag, by default it is latest
DOCKER_BUILD_DIR
The directory containing Dockerfile
REGISTRY_SERVER
Expand All @@ -27,11 +29,15 @@ EOF
}

docker_image_name=''
while getopts ":i:" opt; do
docker_image_tag=latest
while getopts ":it:" opt; do
case $opt in
i)
docker_image_name=$OPTARG
;;
t)
docker_image_tag=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
Expand Down Expand Up @@ -62,7 +68,7 @@ REGISTRY_PASSWD=$5
BUILD_NUMBER="0"
}

remote_image_name=$REGISTRY_SERVER:$REGISTRY_PORT/$docker_image_name:latest
remote_image_name=$REGISTRY_SERVER:$REGISTRY_PORT/$docker_image_name:$docker_image_tag
timestamp="$(date -u +%Y%m%d)"
build_version="${timestamp}.${BUILD_NUMBER}"
build_remote_image_name=$REGISTRY_SERVER:$REGISTRY_PORT/$docker_image_name:$build_version
Expand Down