forked from sehrope/dokku-logging-supervisord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-release
executable file
·37 lines (30 loc) · 1.15 KB
/
post-release
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
#!/bin/bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
IMAGE="dokku/$1"
SCALE_FILE="$DOKKU_ROOT/$APP/SCALE"
PLUGIN_DIR=$(dirname $0)
. "$PLUGIN_DIR/lib/helpers"
# Check for Procfile
id=$(docker run -d $IMAGE test -f app/Procfile)
if [ $(docker wait $id) -ne 0 ]; then
exit 0
fi
copy_to_container "$PLUGIN_DIR/lib/procfile-to-supervisord" /build/procfile-to-supervisord
if [ -f "$SCALE_FILE" ]; then
echo "Found SCALE file: $SCALE_FILE"
copy_to_container "$SCALE_FILE" /app/SCALE
fi
echo "-----> Injecting Logging Supervisor ..."
if docker run -a stdout -i $IMAGE /usr/bin/dpkg -s supervisor > /dev/null; then
echo "supervisor is already installed (skipping apt-get update/install)"
else
echo "supervisor is not installed (will install via apt-get)"
id=$(docker run -i -a stdin $IMAGE /bin/bash -c "apt-get update && apt-get install -y supervisor && apt-get clean")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null
fi
# Replace /start with our custom runner:
id=$(cat "$PLUGIN_DIR/lib/runner" | docker run -i -a stdin $IMAGE /bin/bash -c "cat > /start")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null