Use DOKKU_ROOT instead of HOME.
HOME is not consistent if dokku is ran e.g. as root (for setup). The DOKKU_ROOT variable will also make it possible to have the repositories stored in an arbitrary location (works-ish right now)
This commit is contained in:
22
dokku
22
dokku
@@ -2,6 +2,8 @@
|
|||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
|
export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
|
||||||
|
export DOKKU_ROOT=${DOKKU_ROOT:="/home/dokku"}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
receive)
|
receive)
|
||||||
APP="$2"; IMAGE="app/$APP"
|
APP="$2"; IMAGE="app/$APP"
|
||||||
@@ -38,8 +40,8 @@ case "$1" in
|
|||||||
release)
|
release)
|
||||||
APP="$2"; IMAGE="$3"
|
APP="$2"; IMAGE="$3"
|
||||||
pluginhook pre-release $APP $IMAGE
|
pluginhook pre-release $APP $IMAGE
|
||||||
if [[ -f "$HOME/$APP/ENV" ]]; then
|
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
|
||||||
id=$(cat "$HOME/$APP/ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/app-env.sh")
|
id=$(cat "$DOKKU_ROOT/$APP/ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/app-env.sh")
|
||||||
test $(docker wait $id) -eq 0
|
test $(docker wait $id) -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
fi
|
fi
|
||||||
@@ -49,20 +51,20 @@ case "$1" in
|
|||||||
deploy)
|
deploy)
|
||||||
APP="$2"; IMAGE="$3"
|
APP="$2"; IMAGE="$3"
|
||||||
pluginhook pre-deploy $APP $IMAGE
|
pluginhook pre-deploy $APP $IMAGE
|
||||||
if [[ ! -f "$HOME/$APP/PORT" ]]; then
|
if [[ ! -f "$DOKKU_ROOT/$APP/PORT" ]]; then
|
||||||
# First deploy
|
# First deploy
|
||||||
id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web")
|
id=$(docker run -d -p 5000 -e PORT=5000 $IMAGE /bin/bash -c "/start web")
|
||||||
echo $id > "$HOME/$APP/CONTAINER"
|
echo $id > "$DOKKU_ROOT/$APP/CONTAINER"
|
||||||
port=$(docker port $id 5000)
|
port=$(docker port $id 5000)
|
||||||
echo $port > "$HOME/$APP/PORT"
|
echo $port > "$DOKKU_ROOT/$APP/PORT"
|
||||||
echo "http://$(< "$HOME/HOSTNAME"):$port" > "$HOME/$APP/URL"
|
echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL"
|
||||||
else
|
else
|
||||||
# Regular deploy
|
# Regular deploy
|
||||||
oldid=$(< "$HOME/$APP/CONTAINER")
|
oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||||
docker kill $oldid > /dev/null
|
docker kill $oldid > /dev/null
|
||||||
port=$(< "$HOME/$APP/PORT")
|
port=$(< "$DOKKU_ROOT/$APP/PORT")
|
||||||
id=$(docker run -d -p ":$port" -e "PORT=$port" $IMAGE /bin/bash -c "/start web")
|
id=$(docker run -d -p ":$port" -e "PORT=$port" $IMAGE /bin/bash -c "/start web")
|
||||||
echo $id > "$HOME/$APP/CONTAINER"
|
echo $id > "$DOKKU_ROOT/$APP/CONTAINER"
|
||||||
fi
|
fi
|
||||||
pluginhook post-deploy $APP $port
|
pluginhook post-deploy $APP $port
|
||||||
;;
|
;;
|
||||||
@@ -84,7 +86,7 @@ case "$1" in
|
|||||||
|
|
||||||
# temporary hack for https://github.com/progrium/dokku/issues/82
|
# temporary hack for https://github.com/progrium/dokku/issues/82
|
||||||
deploy:all)
|
deploy:all)
|
||||||
for app in $(ls -d $HOME/*/); do
|
for app in $(ls -d $DOKKU_ROOT/*/); do
|
||||||
APP=$(basename $app);
|
APP=$(basename $app);
|
||||||
IMAGE="app/$APP"
|
IMAGE="app/$APP"
|
||||||
dokku deploy $APP $IMAGE
|
dokku deploy $APP $IMAGE
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ set -e; case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
APP="$2"; IMAGE="app/$APP";
|
APP="$2"; IMAGE="app/$APP";
|
||||||
if [[ ! -d "$HOME/$APP" ]]; then
|
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
|
||||||
echo "App does not exist"
|
echo "App does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pluginhook pre-delete $APP
|
pluginhook pre-delete $APP
|
||||||
ID=$(< "$HOME/$APP/CONTAINER")
|
ID=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||||
|
|
||||||
docker stop $ID > /dev/null
|
docker stop $ID > /dev/null
|
||||||
docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null &
|
docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null &
|
||||||
@@ -22,7 +22,7 @@ set -e; case "$1" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
logs)
|
logs)
|
||||||
CONTAINER=$(<$HOME/$2/CONTAINER)
|
CONTAINER=$(<$DOKKU_ROOT/$2/CONTAINER)
|
||||||
docker logs $CONTAINER | tail -n 100
|
docker logs $CONTAINER | tail -n 100
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ set -e; case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
APP="$2"; IMAGE="app/$APP"
|
APP="$2"; IMAGE="app/$APP"
|
||||||
if [[ ! -d "$HOME/$APP" ]]; then
|
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
|
||||||
echo "App $APP does not exist"
|
echo "App $APP does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -42,13 +42,13 @@ set -e; case "$1" in
|
|||||||
|
|
||||||
url)
|
url)
|
||||||
APP="$2";
|
APP="$2";
|
||||||
if [[ ! -d "$HOME/$APP" ]]; then
|
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
|
||||||
echo "App $APP does not exist"
|
echo "App $APP does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$HOME/$APP/URL" ]]; then
|
if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then
|
||||||
echo $(< "$HOME/$APP/URL")
|
echo $(< "$DOKKU_ROOT/$APP/URL")
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
sed -i 's/docker -d$/docker -d -r=true/' /etc/init/docker.conf
|
sed -i 's/docker -d$/docker -d -r=true/' /etc/init/docker.conf
|
||||||
|
|
||||||
echo $HOSTNAME > $HOME/HOSTNAME
|
echo $HOSTNAME > $DOKKU_ROOT/HOSTNAME
|
||||||
|
|
||||||
|
|
||||||
# temporary hack for https://github.com/progrium/dokku/issues/82
|
# temporary hack for https://github.com/progrium/dokku/issues/82
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
[[ -n $1 ]] && rm -r "/home/git/$1" > /dev/null
|
[[ -n $1 ]] && rm -r "$DOKKU_ROOT/$1" > /dev/null
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ if [[ $1 == config ]] || [[ $1 == config:* ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
APP="$2"
|
APP="$2"
|
||||||
ENV_FILE="$HOME/$APP/ENV"
|
ENV_FILE="$DOKKU_ROOT/$APP/ENV"
|
||||||
|
|
||||||
# Check if app exists with the same name
|
# Check if app exists with the same name
|
||||||
if [ ! -d "$HOME/$APP" ]; then
|
if [ ! -d "$DOKKU_ROOT/$APP" ]; then
|
||||||
echo "App $APP does not exist"
|
echo "App $APP does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -105,7 +105,7 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP="$2"; APP_DIR="$HOME/$APP"
|
APP="$2"; APP_DIR="$DOKKU_ROOT/$APP"
|
||||||
ENV_ADD=""
|
ENV_ADD=""
|
||||||
ENV_TEMP=`cat "${ENV_FILE}"`
|
ENV_TEMP=`cat "${ENV_FILE}"`
|
||||||
ID=$(< "$APP_DIR/CONTAINER")
|
ID=$(< "$APP_DIR/CONTAINER")
|
||||||
@@ -149,7 +149,7 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP="$2"; APP_DIR="$HOME/$APP"
|
APP="$2"; APP_DIR="$DOKKU_ROOT/$APP"
|
||||||
ENV_TEMP=`cat "${ENV_FILE}"`
|
ENV_TEMP=`cat "${ENV_FILE}"`
|
||||||
ID=$(< "$APP_DIR/CONTAINER")
|
ID=$(< "$APP_DIR/CONTAINER")
|
||||||
VARS="${*:3}"
|
VARS="${*:3}"
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ case "$1" in
|
|||||||
|
|
||||||
git-*)
|
git-*)
|
||||||
APP="$(echo $2 | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g')"
|
APP="$(echo $2 | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g')"
|
||||||
APP_PATH=$HOME/$APP
|
APP_PATH=$DOKKU_ROOT/$APP
|
||||||
|
|
||||||
if [[ $1 == "git-receive-pack" && ! -d $APP_PATH ]]; then
|
if [[ $1 == "git-receive-pack" && ! -d $APP_PATH ]]; then
|
||||||
git init --bare $APP_PATH > /dev/null
|
git init --bare $APP_PATH > /dev/null
|
||||||
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
|
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
|
||||||
cat > $PRERECEIVE_HOOK <<EOF
|
cat > $PRERECEIVE_HOOK <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cat | dokku git-hook $APP
|
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
|
||||||
EOF
|
EOF
|
||||||
chmod +x $PRERECEIVE_HOOK
|
chmod +x $PRERECEIVE_HOOK
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ if ! grep -q dokku-nginx-reload "/etc/sudoers"; then
|
|||||||
rm /tmp/sudoers.new
|
rm /tmp/sudoers.new
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "include $HOME/*/nginx.conf;" > /etc/nginx/conf.d/dokku.conf
|
echo "include $DOKKU_ROOT/*/nginx.conf;" > /etc/nginx/conf.d/dokku.conf
|
||||||
|
|
||||||
sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf
|
sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf
|
||||||
|
|
||||||
[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME > $HOME/VHOST
|
[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME > $DOKKU_ROOT/VHOST
|
||||||
|
|
||||||
/etc/init.d/nginx start
|
/etc/init.d/nginx start
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
APP="$1"; PORT="$2"
|
APP="$1"; PORT="$2"
|
||||||
WILDCARD_SSL="$HOME/ssl"
|
WILDCARD_SSL="$DOKKU_ROOT/ssl"
|
||||||
SSL="$HOME/$APP/ssl"
|
SSL="$DOKKU_ROOT/$APP/ssl"
|
||||||
|
|
||||||
if [[ -f "$HOME/VHOST" ]]; then
|
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then
|
||||||
VHOST=$(< "$HOME/VHOST")
|
VHOST=$(< "$DOKKU_ROOT/VHOST")
|
||||||
SUBDOMAIN=${APP/%\.${VHOST}/}
|
SUBDOMAIN=${APP/%\.${VHOST}/}
|
||||||
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
|
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
|
||||||
hostname="${APP/\//-}"
|
hostname="${APP/\//-}"
|
||||||
@@ -21,7 +21,7 @@ if [[ -f "$HOME/VHOST" ]]; then
|
|||||||
|
|
||||||
# ssl based nginx.conf
|
# ssl based nginx.conf
|
||||||
if [[ -n "$SSL_INUSE" ]]; then
|
if [[ -n "$SSL_INUSE" ]]; then
|
||||||
cat<<EOF > $HOME/$APP/nginx.conf
|
cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf
|
||||||
upstream $APP { server 127.0.0.1:$PORT; }
|
upstream $APP { server 127.0.0.1:$PORT; }
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
@@ -54,10 +54,10 @@ server {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "https://$hostname" > "$HOME/$APP/URL"
|
echo "https://$hostname" > "$DOKKU_ROOT/$APP/URL"
|
||||||
else
|
else
|
||||||
# default nginx.conf
|
# default nginx.conf
|
||||||
cat<<EOF > $HOME/$APP/nginx.conf
|
cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf
|
||||||
upstream $APP { server 127.0.0.1:$PORT; }
|
upstream $APP { server 127.0.0.1:$PORT; }
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
@@ -76,7 +76,7 @@ server {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "http://$hostname" > "$HOME/$APP/URL"
|
echo "http://$hostname" > "$DOKKU_ROOT/$APP/URL"
|
||||||
fi
|
fi
|
||||||
pluginhook nginx-pre-reload $APP
|
pluginhook nginx-pre-reload $APP
|
||||||
sudo /etc/init.d/nginx reload
|
sudo /etc/init.d/nginx reload
|
||||||
|
|||||||
Reference in New Issue
Block a user