-
-
Save jonfriesen/18253e5c77382a7e2c23258aa0ff6820 to your computer and use it in GitHub Desktop.
Small helper script that automates Docker building and pushing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
PARENT_DIR=$(basename "${PWD%/*}") | |
CURRENT_DIR="${PWD##*/}" | |
IMAGE_NAME="$PARENT_DIR/$CURRENT_DIR" | |
TAG="${1}" | |
REGISTRY="hub.docker.com" | |
docker build -t ${REGISTRY}/${IMAGE_NAME}:${TAG} . | |
docker tag ${REGISTRY}/${IMAGE_NAME}:${TAG} ${REGISTRY}/${IMAGE_NAME}:latest | |
docker push ${REGISTRY}/${IMAGE_NAME} | |
docker tag ${REGISTRY}/${IMAGE_NAME}:latest ${REGISTRY}/${IMAGE_NAME}:${TAG} | |
docker push ${REGISTRY}/${IMAGE_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment