From eef39c30d3b12360a3de873c01279af04865088a Mon Sep 17 00:00:00 2001 From: alexanderbeletsky Date: Fri, 19 Jul 2013 01:07:54 +0300 Subject: [PATCH 1/2] issue #92: inserting environment file to docker instance --- AUTHORS | 1 + README.md | 17 ++++++++++++++--- dokku | 12 ++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index dc997e183..77ef1fd85 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,7 @@ # This file lists all individuals having contributed content to the repository. # Alexander +Alexander Beletsky Felipe Coury Jeff Lindsay Leo Unbekandt diff --git a/README.md b/README.md index ce742dd08..a5e1763a9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ 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. +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. 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 @@ -43,14 +43,25 @@ the Heroku Node.js sample app. All you have to do is add a remote to name the ap remote: -----> Building node-js-app ... remote: Node.js app detected remote: -----> Resolving engine versions - + ... blah blah blah ... - + remote: -----> Application deployed: remote: http://node-js-app.progriumapp.com You're done! +## Environment setup + +Typically application requires some environment variables to be set up for proper run. Environment variables might contain some private date, 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: + + export NODE_ENV=production + export MONGODB_PASSWORD=password + +Next time the application is deployed, those variables would be exposed by `start` script. + ## Advanced installation (for development) If you plan on developing dokku, the easiest way to install from your own repository is cloning diff --git a/dokku b/dokku index 2831de942..de72c16c6 100755 --- a/dokku +++ b/dokku @@ -7,6 +7,9 @@ case "$1" in echo "-----> Building $APP ..." cat | dokku build $IMAGE echo "-----> Build complete!" + echo "-----> Setting up ..." + dokku setup $APP $IMAGE + echo "-----> Setup complete!" echo "-----> Deploying $APP ..." dokku deploy $APP $IMAGE echo "=====> Application deployed:" @@ -25,6 +28,15 @@ case "$1" in docker commit $id $IMAGE > /dev/null ;; + setup) + APP="$2"; IMAGE="$3" + if [[ -f "$HOME/$APP/ENV" ]]; then + id=$(cat "$HOME/$APP/ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "cat > /app/.app-env") + test $(docker wait $id) -eq 0 + docker commit $id $IMAGE > /dev/null + fi + ;; + deploy) APP="$2"; IMAGE="$3" pluginhook pre-deploy $APP $IMAGE From ad6459a70cc203d2faa412c8661fddc72e09d2e7 Mon Sep 17 00:00:00 2001 From: alexanderbeletsky Date: Sat, 20 Jul 2013 09:59:22 +0300 Subject: [PATCH 2/2] corrected after @progrium comments --- dokku | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dokku b/dokku index de72c16c6..64890bcf5 100755 --- a/dokku +++ b/dokku @@ -7,9 +7,9 @@ case "$1" in echo "-----> Building $APP ..." cat | dokku build $IMAGE echo "-----> Build complete!" - echo "-----> Setting up ..." - dokku setup $APP $IMAGE - echo "-----> Setup complete!" + echo "-----> Releasing $APP ..." + dokku release $APP $IMAGE + echo "-----> Release complete!" echo "-----> Deploying $APP ..." dokku deploy $APP $IMAGE echo "=====> Application deployed:" @@ -28,10 +28,10 @@ case "$1" in docker commit $id $IMAGE > /dev/null ;; - setup) + release) APP="$2"; IMAGE="$3" if [[ -f "$HOME/$APP/ENV" ]]; then - id=$(cat "$HOME/$APP/ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "cat > /app/.app-env") + 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") test $(docker wait $id) -eq 0 docker commit $id $IMAGE > /dev/null fi