-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpre-deploy
executable file
·43 lines (31 loc) · 1.34 KB
/
pre-deploy
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
# Runs application varnish in container
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../../../dokku/plugins/common/functions"
# load common functions
. $(dirname "$0")/functions
check_app_name $1
APP="$1"
PORT="$2"
dokku_log_info1 "Varnish pre-deploy for $APP"
init_common_vars
# Check if an existing varnish volume exists
VARNISH_IMAGE_ID=$(docker images | grep "$VARNISH_IMAGE" | awk '{print $3}')
if [[ -n $VARNISH_IMAGE_ID ]]; then
dokku_log_info1 "Checking status of Varnish"
# Check if varnish container is installed
IMAGE=$(docker images | grep $DOCKER_VARNISH_IMAGE | awk '{print $3}')
check_varnish_image $IMAGE
dokku_log_verbose "Found image $VARNISH_IMAGE instance"
VARNISH_CONTAINER=$(get_app_running_container_ids $VARNISH_IMAGE)
if [[ -n $VARNISH_CONTAINER ]]; then
dokku_log_verbose "Checking status... ok."
else
dokku_log_verbose "Checking status... stopped."
port="`cat $PORT_PROPERTY`"
# Launch container
ID=$(docker run -e CACHE_SIZE="$VARNISH_CACHE_SIZE" -e THROTTLE_LIMIT="$VARNISH_THROTTLE_LIMIT" -e GRACE_TTL="$VARNISH_GRACE_TTL" -e GRACE_MAX="$VARNISH_GRACE_MAX" -e BACKEND_PORT_${APP_PORT}_TCP_ADDR=$LOCAL_IP -e BACKEND_ENV_PORT=$APP_PORT -p $port:$VARNISH_PORT -d $VARNISH_IMAGE /bin/run.sh)
sleep 1
dokku_log_verbose "Started $VARNISH_IMAGE"
fi
fi