forked from devopsdays/devopsdays-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hugoserver.sh
executable file
·40 lines (33 loc) · 1.04 KB
/
hugoserver.sh
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
40
#!/bin/bash
#
# File: hugoServer
#
# Purpose: Run the Hugo container as a local server
#
# This requires Docker 17.06.0-ce or above.
#
# NOTE: The docker image provided by jojomi is not managed or audited by devopsdays
if [ "$(uname)" == "Linux" ]; then
MOUNT_OPTION="Z"
else
MOUNT_OPTION="cached"
fi
if [ $# -eq 1 ]; then
HUGO_BASEURL=$1
else
HUGO_BASEURL="http://localhost:1313"
fi
# Get the current user/group so we can run hugo as this user/group
CURUSER=$(id -u)
CURGROUP=$(id -g)
# You can set HUGO_IMAGE in the env to overwrite or it will default to this version
HUGO_IMAGE=${HUGO_IMAGE:-cibuilds/hugo:0.126.1}
echo "HUGO_BASEURL: $HUGO_BASEURL"
docker stop hugo-server 2>/dev/null
docker rm hugo-server 2>/dev/null
[[ -f hugo.log ]] && rm hugo.log
docker run -tip 1313:1313 -v $(pwd):/project:${MOUNT_OPTION} \
-e HUGO_THEME=devopsdays-theme -w /project \
--name hugo-server --entrypoint "" --user $CURUSER:$CURGROUP \
${HUGO_IMAGE} hugo server --watch --bind 0.0.0.0 --baseURL ${HUGO_BASEURL} \
--noHTTPCache --logLevel info