diff --git a/Makefile b/Makefile index 66385fadb..2cf37f41e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -GITRECEIVE_URL ?= https://raw.github.com/progrium/gitreceive/master/gitreceive SSHCOMMAND_URL ?= https://raw.github.com/progrium/sshcommand/master/sshcommand PLUGINHOOK_URL ?= https://s3.amazonaws.com/progrium-pluginhook/pluginhook_0.1.0_amd64.deb STACK_URL ?= github.com/progrium/buildstep @@ -11,19 +10,13 @@ install: dependencies stack copyfiles plugins copyfiles: cp dokku /usr/local/bin/dokku - cp receiver /home/git/receiver mkdir -p /var/lib/dokku/plugins cp -r plugins/* /var/lib/dokku/plugins plugins: pluginhook docker dokku plugins-install -dependencies: gitreceive sshcommand pluginhook docker stack - -gitreceive: - wget -qO /usr/local/bin/gitreceive ${GITRECEIVE_URL} - chmod +x /usr/local/bin/gitreceive - test -f /home/git/receiver || gitreceive init +dependencies: sshcommand pluginhook docker stack sshcommand: wget -qO /usr/local/bin/sshcommand ${SSHCOMMAND_URL} @@ -36,7 +29,6 @@ pluginhook: docker: aufs egrep -i "^docker" /etc/group || groupadd docker - usermod -aG docker git usermod -aG docker dokku curl https://get.docker.io/gpg | apt-key add - echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list diff --git a/README.md b/README.md index eab94b41a..d1b9df6ee 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ This may take around 5 minutes. Certainly better than the several hours it takes ## Configuring -Set up a domain and a wildcard domain pointing to that host. Make sure `/home/git/VHOST` is set to this domain. By default it's set to whatever the hostname the host has. This file only created if the hostname can be resolved by dig (`dig +short $HOSTNAME`). Otherwise you have to create the file manually and set it to your prefered domain. If this file still not present when you push your app, dokku will publish the app with a port number (i.e. `http://example.com:49154` - note the missing subdomain). +Set up a domain and a wildcard domain pointing to that host. Make sure `/home/dokku/VHOST` is set to this domain. By default it's set to whatever the hostname the host has. This file only created if the hostname can be resolved by dig (`dig +short $HOSTNAME`). Otherwise you have to create the file manually and set it to your prefered domain. If this file still not present when you push your app, dokku will publish the app with a port number (i.e. `http://example.com:49154` - note the missing subdomain). You'll have to add a public key associated with a username as it says at the end of the bootstrapper. You'll do something like this from your local machine: - $ cat ~/.ssh/id_rsa.pub | ssh progriumapp.com "sudo gitreceive upload-key progrium" + $ cat ~/.ssh/id_rsa.pub | ssh progriumapp.com "sudo sshcommand acl-add dokku progrium" That's it! @@ -33,7 +33,7 @@ Please check the documentation for your particular build pack as you may need to Let's deploy the [Heroku Node.js sample app](https://github.com/heroku/node-js-sample). All you have to do is add a remote to name the app. It's created on-the-fly. $ cd node-js-sample - $ git remote add progrium git@progriumapp.com:node-js-app + $ git remote add progrium dokku@progriumapp.com:node-js-app $ git push progrium master Counting objects: 296, done. Delta compression using up to 4 threads. @@ -75,7 +75,7 @@ SSH onto the server, then execute: Typically application requires some environment variables to be set up for proper run. Environment variables might contain some private data, like passwords and API keys, so it's not recommend to store them as part of source code. -To setup environment for your application, create file `/home/git/APP_NAME/ENV`. This file is a script that would expose all required environment variables, like: +To setup environment for your application, create file `/home/dokku/APP_NAME/ENV`. This file is a script that would expose all required environment variables, like: export NODE_ENV=production export MONGODB_PASSWORD=password @@ -84,7 +84,7 @@ Next time the application is deployed, those variables would be exposed by `star ## SSL support -Dokku provides easy SSL support from the box. To enable SSL connection to your application, copy `.crt` and `.key` file into `/home/git/:app/ssl` folder (notice, file names should be `server.crt` and `server.key`, respectively). Redeployment of application will be needed to apply SSL configuration. Once it redeployed, application will be accessible by `https://` (redirection from `http://` is applied as well). +Dokku provides easy SSL support from the box. To enable SSL connection to your application, copy `.crt` and `.key` file into `/home/dokku/:app/ssl` folder (notice, file names should be `server.crt` and `server.key`, respectively). Redeployment of application will be needed to apply SSL configuration. Once it redeployed, application will be accessible by `https://` (redirection from `http://` is applied as well). ## Advanced installation (for development) @@ -96,11 +96,11 @@ the repository and calling the install script. Example: $ sudo make install The `Makefile` allows source URLs to be overridden to include customizations from your own -repositories. The DOCKER_URL, GITRECEIVE_URL, PLUGINHOOK_URL, SSHCOMMAND_URL and STACK_URL +repositories. The DOCKER_URL, PLUGINHOOK_URL, SSHCOMMAND_URL and STACK_URL environment variables may be set to override the defaults (see the `Makefile` for how these apply). Example: - $ sudo GITRECEIVE_URL=https://raw.github.com/yourusername/gitreceive/master/gitreceive make install + $ sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/gitreceive make install ## Advanced installation (bootstrap a server from your own repository) @@ -153,7 +153,6 @@ You can use [Github Issues](https://github.com/progrium/dokku/issues), check [Tr * [Docker](https://github.com/dotcloud/docker) - Container runtime and manager * [Buildstep](https://github.com/progrium/buildstep) - Buildpack builder - * [gitreceive](https://github.com/progrium/gitreceive) - Git push interface * [pluginhook](https://github.com/progrium/pluginhook) - Shell based plugins and hooks * [sshcommand](https://github.com/progrium/sshcommand) - Fixed commands over SSH diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 6d895f252..43dfdfa49 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -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/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 diff --git a/plugins/config/commands b/plugins/config/commands index 6574dbf4e..e6e8a79d6 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -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}" diff --git a/plugins/git/commands b/plugins/git/commands new file mode 100755 index 000000000..121bbf081 --- /dev/null +++ b/plugins/git/commands @@ -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/(? /dev/null + PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" + cat > $PRERECEIVE_HOOK <> /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 diff --git a/receiver b/receiver deleted file mode 100755 index 35684d720..000000000 --- a/receiver +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -set -e; set -o pipefail; cat | dokku receive $1 | sed -u "s/^/"$'\e[1G'"/" diff --git a/tests/run_ec2 b/tests/run_ec2 index 7c6981d4d..64ca14304 100755 --- a/tests/run_ec2 +++ b/tests/run_ec2 @@ -36,7 +36,6 @@ set -e echo "-----> Connecting and running bootstrap script..." cat ../bootstrap.sh | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=$PUBLIC_IP sudo bash" 2>&1 | indent echo "-----> Installing SSH public keys..." -cat ~/.ssh/id_rsa.pub | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "sudo gitreceive upload-key test" > /dev/null cat ~/.ssh/id_rsa.pub | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "sudo sshcommand acl-add dokku test" > /dev/null for app_path in apps/*; do app=$(basename $app_path) diff --git a/tests/run_vagrant b/tests/run_vagrant index 929cfda7b..382f55214 100755 --- a/tests/run_vagrant +++ b/tests/run_vagrant @@ -15,7 +15,6 @@ cd "$(dirname $SELF)/.." && vagrant up | indent cd "$(dirname $SELF)" echo "-----> Installing SSH public keys..." -cat $PUBLIC_KEY | ssh -o "StrictHostKeyChecking=no" -i ~/.vagrant.d/insecure_private_key vagrant@dokku.me "sudo gitreceive upload-key test" cat $PUBLIC_KEY | ssh -o "StrictHostKeyChecking=no" -i ~/.vagrant.d/insecure_private_key vagrant@dokku.me "sudo sshcommand acl-add dokku test" for app_path in apps/*; do diff --git a/tests/test_deploy b/tests/test_deploy index 165f72b7b..d1855c4c3 100755 --- a/tests/test_deploy +++ b/tests/test_deploy @@ -11,11 +11,11 @@ git config user.name "Test Robot" git add . git commit -m 'initial commit' REPO="test-$(basename $APP)-$RANDOM" -git remote add target git@$TARGET:$REPO +git remote add target dokku@$TARGET:$REPO git push target master URL=$(ssh dokku@$TARGET url $REPO)$FORWARDED_PORT sleep 2 ./check_deploy $URL && echo "-----> Deploy success!" || { sleep 4 ./check_deploy $URL && echo "-----> Deploy success!" -} \ No newline at end of file +}