Last active
April 30, 2020 04:27
-
-
Save ORESoftware/8b0408b56d17fdc4e26c5d10ea3b7199 to your computer and use it in GitHub Desktop.
Build and run docker image/container
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 | |
# the nice thing about this script is it will remove | |
# existing containers in the background | |
# while the new image is being built | |
set -eo pipefail | |
cd "$(dirname "$BASH_SOURCE")" | |
( | |
set +e; | |
docker stop "local-test" | |
docker rm "local-test" | |
) & | |
commit_id="$(git rev-parse HEAD)" | |
docker build --build-arg commit_id="$commit_id" -t "local-test" . | |
wait; # wait for previous containers to be removed | |
docker run --rm -ti --name "local-test-c" "local-test" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment