mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Replace gitreceive by a git plugin.
This removes the need for two distinct users. Git pushes and dokku commands are sent using the same user.
This commit is contained in:
@@ -6,13 +6,13 @@ set -e; case "$1" in
|
||||
exit 1
|
||||
fi
|
||||
APP="$2"; IMAGE="app/$APP";
|
||||
if [[ ! -d "/home/git/$APP" ]]; then
|
||||
if [[ ! -d "$HOME/$APP" ]]; then
|
||||
echo "App does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pluginhook pre-delete $APP
|
||||
ID=$(< "/home/git/$APP/CONTAINER")
|
||||
ID=$(< "$HOME/$APP/CONTAINER")
|
||||
|
||||
docker stop $ID > /dev/null
|
||||
docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null &
|
||||
@@ -22,7 +22,7 @@ set -e; case "$1" in
|
||||
;;
|
||||
|
||||
logs)
|
||||
CONTAINER=$(</home/git/$2/CONTAINER)
|
||||
CONTAINER=$(<$HOME/$2/CONTAINER)
|
||||
docker logs $CONTAINER | tail -n 100
|
||||
;;
|
||||
|
||||
@@ -32,7 +32,7 @@ set -e; case "$1" in
|
||||
exit 1
|
||||
fi
|
||||
APP="$2"; IMAGE="app/$APP"
|
||||
if [[ ! -d "/home/git/$APP" ]]; then
|
||||
if [[ ! -d "$HOME/$APP" ]]; then
|
||||
echo "App $APP does not exist"
|
||||
exit 1
|
||||
fi
|
||||
@@ -42,13 +42,13 @@ set -e; case "$1" in
|
||||
|
||||
url)
|
||||
APP="$2";
|
||||
if [[ ! -d "/home/git/$APP" ]]; then
|
||||
if [[ ! -d "$HOME/$APP" ]]; then
|
||||
echo "App $APP does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "/home/git/$APP/URL" ]]; then
|
||||
echo $(< "/home/git/$APP/URL")
|
||||
if [[ -f "$HOME/$APP/URL" ]]; then
|
||||
echo $(< "$HOME/$APP/URL")
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
sed -i 's/docker -d$/docker -d -r=true/' /etc/init/docker.conf
|
||||
|
||||
echo $HOSTNAME > /home/git/HOSTNAME
|
||||
echo $HOSTNAME > $HOME/HOSTNAME
|
||||
|
||||
|
||||
# temporary hack for https://github.com/progrium/dokku/issues/82
|
||||
@@ -14,6 +14,6 @@ start on (started docker)
|
||||
|
||||
script
|
||||
sleep 2 # give docker some time
|
||||
sudo -i -u git /usr/local/bin/dokku deploy:all
|
||||
sudo -i -u dokku /usr/local/bin/dokku deploy:all
|
||||
end script
|
||||
EOF
|
||||
|
||||
@@ -8,10 +8,10 @@ if [[ $1 == config ]] || [[ $1 == config:* ]]; then
|
||||
exit 1
|
||||
else
|
||||
APP="$2"
|
||||
ENV_FILE="/home/git/$APP/ENV"
|
||||
ENV_FILE="$HOME/$APP/ENV"
|
||||
|
||||
# Check if app exists with the same name
|
||||
if [ ! -d "/home/git/$APP" ]; then
|
||||
if [ ! -d "$HOME/$APP" ]; then
|
||||
echo "App $APP does not exist"
|
||||
exit 1
|
||||
fi
|
||||
@@ -105,7 +105,7 @@ case "$1" in
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP="$2"; APP_DIR="/home/git/$APP"
|
||||
APP="$2"; APP_DIR="$HOME/$APP"
|
||||
ENV_ADD=""
|
||||
ENV_TEMP=`cat "${ENV_FILE}"`
|
||||
ID=$(< "$APP_DIR/CONTAINER")
|
||||
@@ -149,7 +149,7 @@ case "$1" in
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP="$2"; APP_DIR="/home/git/$APP"
|
||||
APP="$2"; APP_DIR="$HOME/$APP"
|
||||
ENV_TEMP=`cat "${ENV_FILE}"`
|
||||
ID=$(< "$APP_DIR/CONTAINER")
|
||||
VARS="${*:3}"
|
||||
|
||||
39
plugins/git/commands
Executable file
39
plugins/git/commands
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
set -e;
|
||||
|
||||
case "$1" in
|
||||
git-hook)
|
||||
APP=$2
|
||||
|
||||
while read oldrev newrev refname
|
||||
do
|
||||
# Only run this script for the master branch. You can remove this
|
||||
# if block if you wish to run it for others as well.
|
||||
if [[ $refname = "refs/heads/master" ]] ; then
|
||||
git archive $newrev | dokku receive $APP
|
||||
fi
|
||||
|
||||
done
|
||||
;;
|
||||
|
||||
git-*)
|
||||
APP="$(echo $2 | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g')"
|
||||
APP_PATH=$HOME/$APP
|
||||
|
||||
if [[ $1 == "git-receive-pack" && ! -d $APP_PATH ]]; then
|
||||
git init --bare $APP_PATH > /dev/null
|
||||
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
|
||||
cat > $PRERECEIVE_HOOK <<EOF
|
||||
#!/bin/bash
|
||||
cat | dokku git-hook $APP
|
||||
EOF
|
||||
chmod +x $PRERECEIVE_HOOK
|
||||
fi
|
||||
|
||||
args=$@
|
||||
git-shell -c "$args"
|
||||
;;
|
||||
|
||||
esac
|
||||
cat
|
||||
|
||||
@@ -9,15 +9,14 @@ if ! grep -q dokku-nginx-reload "/etc/sudoers"; then
|
||||
touch /etc/sudoers.tmp
|
||||
cp /etc/sudoers /tmp/sudoers.new
|
||||
echo "%dokku ALL=(ALL)NOPASSWD:/etc/init.d/nginx reload # dokku-nginx-reload" >> /tmp/sudoers.new
|
||||
echo "%git ALL=(ALL)NOPASSWD:/etc/init.d/nginx reload # dokku-nginx-reload" >> /tmp/sudoers.new
|
||||
EDITOR="cp /tmp/sudoers.new" visudo
|
||||
rm /tmp/sudoers.new
|
||||
fi
|
||||
|
||||
echo "include /home/git/*/nginx.conf;" > /etc/nginx/conf.d/dokku.conf
|
||||
echo "include $HOME/*/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
|
||||
|
||||
[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME > /home/git/VHOST
|
||||
[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME > $HOME/VHOST
|
||||
|
||||
/etc/init.d/nginx start
|
||||
|
||||
Reference in New Issue
Block a user