Skip to content

Commit

Permalink
Update example to Supfile version 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Dec 15, 2015
1 parent 2327cb9 commit 71d463a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 81 deletions.
99 changes: 57 additions & 42 deletions example/Supfile
Original file line number Diff line number Diff line change
@@ -1,72 +1,65 @@
# Supfile for "Example" server
# Supfile for "Example" Docker service
---
version: 0.3

env: # Environment variables for the commands
env:
# Environment variables for all commands
NAME: example
REPO: github.com/pressly/stackup
REPO: github.com/pressly/sup
BRANCH: master
IMAGE: pressly/example
HOST_PORT: 8000
CONTAINER_PORT: 8000

networks: # Groups of hosts
networks:
# Groups of hosts
local:
env:
CONFIG: example.local.cfg
hosts:
- localhost

dev:
env:
CONFIG: example.dev.cfg
# Extra environment variable for dev hosts only
DOCKER_HOST: tcp://127.0.0.1:2375
hosts:
- docker@192.168.59.103

stg:
env:
CONFIG: example.stg.cfg
hosts:
- ubuntu@stg.example.com

prod:
inventory:
- for i in 4 5 6; do echo "$USER@prod$i.example.com\n"; done
env:
CONFIG: example.prod.cfg
hosts:
- ubuntu@prod1.example.com
- ubuntu@prod2.example.com
- ubuntu@prod3.example.com
inventory: for i in 1 2 3 4; do echo "ubuntu@prod$i.example.com"; done

commands: # Named set of commands to be run remotely
commands:
# Named set of commands to be run remotely
ping:
desc: Print uname and current date/time.
run: uname -a; date

upload:
desc: Upload this repository
pre-build:
desc: Initialize directory
run: mkdir -p /tmp/$IMAGE

build:
desc: Build Docker image from current directory, push to Docker Hub
# local: sup -f ./builder/Supfile $SUP_NETWORK build
upload:
- src: ./
dst: /tmp/$IMAGE

build:
desc: Build Docker image
script: ./scripts/docker-build.sh
once: true

image:
desc: List Docker image
run: sudo docker images | grep $IMAGE
pull:
desc: Pull latest Docker image
run: sudo docker pull $IMAGE

config:
desc: Upload/test config file.
upload:
- src: ./$CONFIG
- src: ./example.$SUP_NETWORK.cfg
dst: /tmp/
run: test -f /tmp/$CONFIG

# pull:
# desc: Pull git repository
# script: ./scripts/docker-pull.sh
run: test -f /tmp/example.$SUP_NETWORK.cfg

stop:
desc: Stop Docker container
Expand All @@ -82,12 +75,29 @@ commands: # Named set of commands to be run remotely

run:
desc: Run Docker container
script: ./scripts/docker-run.sh
run: >
sudo docker run -d \
-p $HOST_PORT:$CONTAINER_PORT \
-v /tmp/example.$SUP_NETWORK.cfg:/etc/example.cfg \
--restart=always \
--name $NAME $IMAGE

restart:
desc: Restart Docker container
run: sudo docker restart $NAME || exit 0

stop-rm-run:
desc: Stop & remove old Docker container, run new one
run: >
sudo docker stop $NAME || :; \
sudo docker rm $NAME || :; \
sudo docker run -d \
-p $HOST_PORT:$CONTAINER_PORT \
-v /tmp/example.$SUP_NETWORK.cfg:/etc/example.cfg \
--restart=always \
--name $NAME $IMAGE
serial: 1

ps:
desc: List running Docker containers
run: sudo docker ps | grep $NAME
Expand All @@ -104,6 +114,13 @@ commands: # Named set of commands to be run remotely
desc: Application health check
run: curl localhost:$HOST_PORT

slack-notify:
desc: Notify Slack about new deployment
run: >
curl -X POST --data-urlencode 'payload={"channel": "#_team_", "text": "['$SUP_NETWORK'] '$(whoami)' deployed '$NAME'"}' \
https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ
once: true

shell:
desc: Interactive shell on all hosts
stdin: true
Expand All @@ -112,18 +129,16 @@ commands: # Named set of commands to be run remotely
exec:
desc: Interactive docker exec on all hosts
stdin: true
run: docker exec -i $NAME bash
run: sudo docker exec -i $NAME bash

targets: # Aliases to run multiple commands at once
targets:
# Aliases to run multiple commands at once
deploy:
#- pull
- upload
- pre-build
- build
- image
- pull
- config
- stop
- rm
- run
- stop-rm-run
- ps
- logs
- health
- health
4 changes: 3 additions & 1 deletion example/scripts/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ sudo rm -rf bin
sudo docker run --rm \
-v $(pwd):/go/src/$REPO/$NAME \
-w /go/src/$REPO/$NAME \
golang:1.4 go build
golang:1.5.2 go build

# Bake bin/* into the resulting image.
sudo docker build --no-cache -t $IMAGE .

sudo docker push $IMAGE
30 changes: 0 additions & 30 deletions example/scripts/docker-pull.sh

This file was deleted.

8 changes: 0 additions & 8 deletions example/scripts/docker-run.sh

This file was deleted.

0 comments on commit 71d463a

Please sign in to comment.