@@ -23,37 +23,11 @@ if [[ "$1" == "" ]]; then
2323fi
2424
2525case " $1 " in
26- receive)
27- verify_app_name " $2 "
28- info " Cleaning up ..."
29- flock -n " $DOKKU_ROOT /cleanup.lock" dokku cleanup || true
30- info " Building $APP ..."
31- cat | dokku build $APP
32- info " Releasing $APP ..."
33- dokku release $APP
34- info " Deploying $APP ..."
35- dokku deploy $APP
36- info2 " Application deployed:"
37- verbose " $( dokku url $APP ) "
38- echo
39- ;;
40-
41- build)
42- verify_app_name " $2 "
43- cat | docker run -i -a stdin progrium/buildstep /bin/bash \
44- -c " mkdir -p /app && tar -xC /app" | commit_image " $IMAGE_GENERIC :build"
45- [[ -d " $CACHE_DIR " ]] || mkdir " $CACHE_DIR "
46- pluginhook pre-build " $APP "
47- DOCKER_ARGS=" $( : | pluginhook docker-args " $APP " build) "
48- docker run -i -a stdin -v " $CACHE_DIR " :/cache \
49- $DOCKER_ARGS \
50- " $IMAGE_GENERIC :build" \
51- /build/builder | attach_and_commit_image " $IMAGE_GENERIC :build"
52- pluginhook post-build " $APP "
53- ;;
54-
5526 release)
5627 verify_app_name " $2 "
28+ verify_max_args " 2" " $@ "
29+
30+ info " Releasing $APP ..."
5731 tag_image " $IMAGE_GENERIC :build" " $IMAGE_GENERIC :release"
5832 pluginhook pre-release " $APP "
5933 if [[ -f " $DOKKU_ROOT /$APP /ENV" ]]; then
@@ -65,6 +39,9 @@ case "$1" in
6539
6640 deploy)
6741 verify_app_name " $2 "
42+ verify_max_args " 2" " $@ "
43+
44+ info " Deploying $APP ..."
6845 tag_image " $IMAGE_GENERIC :release" " $IMAGE_GENERIC :latest"
6946 pluginhook pre-deploy " $APP "
7047
@@ -73,23 +50,32 @@ case "$1" in
7350
7451 # start the app
7552 DOCKER_ARGS=" $( : | pluginhook docker-args " $APP " web) "
76- id=$( docker run -d -p " $APP_PORT " -e PORT=" $APP_PORT " --name=" $APP_NAME " $DOCKER_ARGS " $IMAGE_GENERIC :latest" /bin/bash -c " /start web" )
77- port=$( docker port $id 5000 | sed ' s/0.0.0.0://' )
78- echo " http://$( < " $DOKKU_ROOT /HOSTNAME" ) :$port " > " $DOKKU_ROOT /$APP /URL"
7953
80- # finish deployment
81- pluginhook post-deploy " $APP " " $port "
54+ if docker run --rm " $IMAGE " test -f /exec; then
55+ # buildstep
56+ INT_PORT=" $APP_PORT "
57+ id=$( docker run -d -p " $INT_PORT " -e PORT=" $INT_PORT " --name=" $APP_NAME " $DOCKER_ARGS " $IMAGE_GENERIC :latest" /bin/bash -c " /start web" )
58+ addr=$( docker port $id " $INT_PORT " )
59+ port=${addr#*: }
60+ echo " http://$( < " $DOKKU_ROOT /HOSTNAME" ) :$port " > " $DOKKU_ROOT /$APP /URL"
61+ pluginhook post-deploy " $APP " " $port " " $INT_PORT "
62+ else
63+ # Dockerfile
64+ INT_PORT=" 80"
65+ id=$( docker run -d -p " $INT_PORT " --name=" $APP_NAME " $DOCKER_ARGS " $IMAGE_GENERIC :latest" )
66+ addr=$( docker port $id " $INT_PORT " )
67+ port=${addr#*: }
68+ echo " http://$( < " $DOKKU_ROOT /HOSTNAME" ) :$port " > " $DOKKU_ROOT /$APP /URL"
69+ pluginhook post-deploy " $APP " " $port " " $INT_PORT "
70+ fi
8271
83- # cleanup at the end
84- sleep 2s
85- remove_container $APP_ALL_NAMES
86- flock -n " $DOKKU_ROOT /cleanup.lock" dokku cleanup &
72+ info2 " Application deployed:"
73+ verbose " $( dokku url $APP ) "
8774 ;;
8875
8976 cleanup)
90- # delete all non-running container - it's not very wise
91- # docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm &> /dev/null || true
92- # delete unused images
77+ info " Cleaning up ..."
78+ docker ps -a | grep ' Exit' | grep -v " seconds ago" | awk ' {print $1}' | xargs docker rm & > /dev/null || true
9379 docker images | grep ' <none>' | awk ' {print $3}' | xargs docker rmi & > /dev/null || true
9480 ;;
9581
0 commit comments