Created
February 17, 2017 09:30
-
-
Save tfanme/181f45c8ef11c0838e8dce4bd08cb690 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
#!/bin/bash | |
docker_desc="Dockerfile" # Dockerfile filename | |
image_name="yourimage" # Name and optionally tag of your image | |
file_extension=".tar" # File extension of saved file | |
gz_extension=".gz" # File extension of saved file after compression | |
# Dockerfile exist or not | |
if [ ! -e "$docker_desc" ]; then | |
echo "Dockerfile not found" | |
exit 1 | |
fi | |
# Check image_name options | |
while getopts "t:" opt; do | |
case "$opt" in | |
t) image_name=$OPTARG | |
;; | |
esac | |
done | |
# Delete previously saved file | |
if [ -e "$image_name$file_extension$gz_extension" ]; then | |
echo "Delete previously build file..." | |
rm -rf "$image_name$file_extension$gz_extension" | |
fi | |
# Optional previous project build operation | |
cd ./client && npm run build && cd .. | |
docker build -t "$image_name" ./ | |
docker save -o "$image_name$file_extension" "$image_name" | |
echo "Begin ompress..." | |
gzip "$image_name$file_extension" | |
echo "Done, enjoy it!" | |
# run | |
# docker run -d -p 49170:80 "$image_name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment