forked from dokku/dokku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dokku
executable file
·69 lines (62 loc) · 1.76 KB
/
dokku
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
#!/bin/bash
set -e
export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
case "$1" in
receive)
APP="$2"; IMAGE="app/$APP"
echo "-----> Building $APP ..."
cat | dokku build $IMAGE
echo "-----> Build complete!"
echo "-----> Deploying $APP ..."
dokku deploy $APP $IMAGE
echo "=====> Application deployed:"
echo " $(dokku url $APP)"
echo
;;
build)
IMAGE="$2"
id=$(cat | docker run -i -a stdin progrium/buildstep /bin/bash -c "mkdir -p /app && tar -xC /app")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null
id=$(docker run -d $IMAGE /build/builder)
docker attach $id
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null
;;
deploy)
APP="$2"; IMAGE="$3"
pluginhook pre-deploy $APP $IMAGE
if [[ ! -f "$HOME/$APP/PORT" ]]; then
# First deploy
id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web")
echo $id > "$HOME/$APP/CONTAINER"
port=$(docker port $id 5000)
echo $port > "$HOME/$APP/PORT"
echo "$(< "$HOME/HOSTNAME"):$port" > "$HOME/$APP/ADDRESS"
else
# Regular deploy
oldid=$(< "$HOME/$APP/CONTAINER")
docker kill $oldid > /dev/null
port=$(< "$HOME/$APP/PORT")
id=$(docker run -d -p ":$port" -e "PORT=$port" $IMAGE /bin/bash -c "/start web")
echo $id > "$HOME/$APP/CONTAINER"
fi
pluginhook post-deploy $APP $port
;;
plugins)
ls -1 -d $PLUGIN_PATH/*/
;;
plugins-install)
pluginhook install
;;
help)
cat<<EOF | pluginhook commands help | sort
help Print the list of commands
plugins Print active plugins
plugins-install Install active plugins
EOF
;;
*)
pluginhook commands "$@"
;;
esac