-
Notifications
You must be signed in to change notification settings - Fork 6
/
make.sh
executable file
·94 lines (78 loc) · 1.76 KB
/
make.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# ############ ############ ############
# Usage:
# with defaults:
# ./make.sh
# ./make.sh server
# or:
# ARGS="-it" IMAGE="riccardoblb/buildenvs:hugo" RUNTIME="docker" ./make.sh
# PORT="1313" ARGS="-it" IMAGE="riccardoblb/buildenvs:hugo" RUNTIME="docker" ./make.sh server
# ############ ############ ############
set -x
if [ "$IMAGE" = "" ];
then
export IMAGE="jmonkeyengine/buildenv-jme3:hugo"
fi
userUID=`id -u`
groupUID=`id -g`
if [ "$CMD" = "" ];
then
export CMD="hugo $@"
fi
if [ "$DONT_COMPILE_LESS" = "" ];
then
export CMD="sleep 2&&echo 'export default \"`date +%s`\"'> static/js/build-id.js&&lessc static/css/style.less static/css/style.css&&$CMD"
fi
if [ "$ARGS" = "" ];
then
if [ "$HEADLESS" = "" ];
then
export ARGS="$ARGS -it"
fi
fi
if [ "$RUNTIME" = "" ];
then
if [ "`which podman`" != "" ];then
export RUNTIME="podman"
else
export RUNTIME="docker"
if [ "$SUDO_USER" != "" ];
then
userUID=`id -u $SUDO_USER`
groupUID=`id -g $SUDO_USER`
fi
ARGS="$ARGS -u=$userUID:$groupUID"
fi
fi
if [ "$PORT" = "" ];
then
if [ "$1" = "server" ];
then
export PORT="1313"
fi
fi
if [ "$PORT" != "" ];
then
export ARGS="$ARGS -p$PORT:1313"
fi
if [ "$1" = "server" ];
then
export CMD="$CMD --bind 0.0.0.0"
fi
ENV_FILE=""
if [ -f ".local-env" ];
then
if [ "$NO_CONTAINER" != "" ];
then
export $(cat .local-env | xargs)
fi
ENV_FILE="--env-file=.local-env"
fi
set -x
if [ "$NO_CONTAINER" = "" ];
then
$RUNTIME pull $IMAGE
$RUNTIME run -v"$PWD:$PWD" $ENV_FILE $RUN_AS -w $PWD $ARGS --rm $IMAGE bash -c "$CMD"
else
eval "$CMD"
fi