forked from KxSystems/docs-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_docs.sh
More file actions
executable file
·39 lines (38 loc) · 1.19 KB
/
docker_docs.sh
File metadata and controls
executable file
·39 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
function usage(){
printf "Usage:\n\tdocker_docs.sh {serve|build|shell} [OPTS]\n\n\t" >&2
printf -- "-p PORT\n\t\tPort used for preview site, only used for serve option, the default is 9000\n\t" >&2
printf -- "-v {v1|v2}\n\t\tVersion of the site to build, this will run the corresponding container, default is v1\n\t" >&2
printf -- "-t {docker tag}\n\t\trun a specific version of the docker container, default is 'latest'\n" >&2
}
case $1 in
serve) command=serve;;
build) command=build;;
shell) command=shell;;
*) usage ; exit 1 ;;
esac
shift
PORT=9000
IMAGE=kxsys/docs-v1
TAG=latest
while getopts ":hp:v:t:" opt; do
case ${opt} in
h )
usage ; exit 0 ;;
p )
PORT=$OPTARG ;;
v )
IMAGE=kxsys/docs-$OPTARG ;;
t )
TAG=$OPTARG ;;
\? ) usage ; exit 1 ;;
esac
done
IMAGE=${IMAGE}:${TAG}
DOCPATH="$( cd "$(dirname "$0")" ; pwd -P )"
case $command in
serve) docker run --rm -it -v $DOCPATH:/docs -p $PORT:$PORT -e PORT=$PORT $IMAGE serve ;;
build) docker run --rm -v $DOCPATH:/docs $IMAGE build ;;
shell) docker run --rm -it -v $DOCPATH:/docs $IMAGE shell ;;
*) usage; exit 1 ;;
esac