first pass at dockerfile support

This commit is contained in:
Michael Hobbs
2015-02-07 10:47:04 -08:00
parent 122df4cdaf
commit 7357df7c9d
18 changed files with 292 additions and 68 deletions

View File

@@ -1,19 +1,30 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../common/functions"
git_archive_all() {
APP=$1; REV=$2
git_build_app_repo() {
verify_app_name "$1"
APP="$1"; REV="$2"
# clean up after ourselves
TMP_WORK_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_WORK_DIR" > /dev/null' RETURN
# git clone
chmod 755 $TMP_WORK_DIR
unset GIT_DIR GIT_WORK_TREE
pushd $TMP_WORK_DIR > /dev/null
git clone -q $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null
git clone -q "$DOKKU_ROOT/$APP" "$TMP_WORK_DIR" &> /dev/null
git config advice.detachedHead false
git checkout $REV &> /dev/null
git checkout "$REV" &> /dev/null
git submodule update --init --recursive &> /dev/null
find -name .git -prune -exec rm -rf {} \; > /dev/null
tar c .
rm -rf $TMP_WORK_DIR > /dev/null
if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then
dokku receive "$APP" "dockerfile" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/"
else
dokku receive "$APP" "buildstep" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/"
fi
}
case "$1" in
@@ -25,7 +36,8 @@ case "$1" in
# 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
dokku git-build $APP $newrev
# broken out into pluginhook so we might support other methods to receive an app
pluginhook receive-app $APP $newrev
else
echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master."
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\/}:master'"
@@ -56,7 +68,7 @@ case "$1" in
else
REF=$(< "$DOKKU_ROOT/$APP/refs/heads/master")
fi
git_archive_all $APP $REF | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/"
git_build_app_repo $APP $REF
;;
git-*)