-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun
More file actions
executable file
·43 lines (35 loc) · 870 Bytes
/
run
File metadata and controls
executable file
·43 lines (35 loc) · 870 Bytes
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
#!/usr/bin/env bash
HUGO_IMAGE='docker.io/hugomods/hugo:latest'
ENGINE_COMMAND="$(command -v podman 2>/dev/null || command -v docker 2>/dev/null)"
log() {
printf "%s\n" "$*" >&2
}
if [ -z "$ENGINE_COMMAND" ]; then
log 'Neither Docker nor Podman are available.'
exit 1
fi
if ! $ENGINE_COMMAND info &>/dev/null; then
log "Failed to execute $ENGINE_COMMAND. Check if you have the correct permissions."
exit 1
fi
BASE_COMMAND="\
$ENGINE_COMMAND run \
--tty \
--interactive \
--rm=true \
--net=host \
-v '$PWD':/src:Z \
"
case "$1" in
hugo)
COMMAND="$BASE_COMMAND --entrypoint='hugo' $HUGO_IMAGE ${@:2}"
;;
yarn)
COMMAND="$BASE_COMMAND --entrypoint='yarn' $HUGO_IMAGE ${@:2}"
;;
*)
echo "Usage: $0 <hugo|yarn> [parameters]"
exit 1
;;
esac
eval "$COMMAND"