Created
September 23, 2019 16:29
-
-
Save phuctm97/91f9c1e485f0557fedb63c8c40e67994 to your computer and use it in GitHub Desktop.
Go RESTful Series
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 | |
# Exit immediately on failure. | |
set -e | |
# Derive local workspace's absolute path from script's path. | |
LOCAL_WORKDIR=$(cd $(dirname $(dirname "${BASH_SOURCE[0]}")) >/dev/null 2>&1 && pwd) | |
main() { | |
# Variables. | |
local image_tag=go-restful:dev | |
local local_workdir=$LOCAL_WORKDIR | |
local local_port=8000 | |
local container_name=go-restful-dev | |
local container_workdir=/root/project | |
local container_port=8000 | |
# Build image (if necessary). | |
docker build --rm -t $image_tag $local_workdir | |
# Start container. | |
docker run --rm -it \ | |
--name $container_name \ | |
--volume $local_workdir:$container_workdir \ | |
--workdir $container_workdir \ | |
--publish $local_port:$container_port \ | |
$image_tag | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment