Created
June 18, 2019 02:03
-
-
Save tammersaleh/f84274d516cd43d426757bf06323a13d to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
set -eou pipefail | |
[[ "$#" == 1 ]] && cd "$1" | |
if [[ ! -f Dockerfile ]]; then | |
echo "Usage: $(basename $BASH_SOURCE) [directory]" | |
echo "Builds the docker image locally" | |
echo | |
echo "Error: No Dockerfile found" | |
exit 1 | |
fi | |
user="superorbital" | |
image=${PWD##*/} | |
docker build -t "$user/$image:latest" . |
This file contains 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
#!/usr/bin/env bash | |
set -eou pipefail | |
[[ "$#" == 1 ]] && cd "$1" | |
if [[ ! -f VERSION ]]; then | |
echo "Usage: $(basename $BASH_SOURCE) [directory]" | |
echo "Bumps the version for a docker image" | |
echo | |
echo "Error: No VERSION file found" | |
exit 1 | |
fi | |
current_version_number="$(< VERSION)" | |
new_version_number="$((current_version_number+1))" | |
version_string="v$new_version_number" | |
echo "version: $version_string" | |
echo $new_version_number > VERSION |
This file contains 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
#!/usr/bin/env bash | |
set -eou pipefail | |
[[ "$#" == 1 ]] && cd "$1" | |
if [[ ! -f Dockerfile ]]; then | |
echo "Usage: $(basename $BASH_SOURCE) [directory]" | |
echo "Releases the docker image" | |
echo | |
echo "Error: No Dockerfile found" | |
exit 1 | |
fi | |
user="superorbital" | |
image=${PWD##*/} | |
version_string="v$(<VERSION)" | |
set -x | |
# Tag and push in Git | |
git add -A . | |
git commit -m "Tagging $image at $version_string" | |
git push | |
git tag -a "$image/$version_string" -m "Tagging $image at $version_string" | |
git push --tags | |
# Tag and push in Dockerhub | |
docker tag $user/$image:latest $user/$image:$version_string | |
docker push $user/$image:latest | |
docker push $user/$image:$version_string | |
docker images $user/$image |
This file contains 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
#!/usr/bin/env bash | |
set -eou pipefail | |
if [[ ! -f Dockerfile ]]; then | |
echo "Usage: $(basename "$0") [CMD]" | |
echo "Runs the docker image locally. Run 'build' first." | |
echo | |
echo "Error: No Dockerfile found" | |
exit 1 | |
fi | |
user="superorbital" | |
image=${PWD##*/} | |
OPTIONS="" | |
[[ -f .docker-run-options ]] && OPTIONS="$OPTIONS $(< .docker-run-options)" | |
docker container prune -f | |
set -x | |
# shellcheck disable=SC2086 | |
docker run $OPTIONS "$user/$image:latest" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These assume the directory containing the Dockerfile is named the same as the image repository