Skip to content

Commit

Permalink
New deployment mechanism for Triton
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDickinson committed Feb 5, 2017
1 parent 6603acf commit 067568a
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
#
# See: https://docs.docker.com/compose/env-file/
#
CONSUL=consul
COMPOSE_PROJECT_NAME=synchro
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail
.DEFAULT_GOAL := build

# Build the docker images
#
build:
build: build-nginx build-synchro build-stashbox build-redis

build-nginx:
docker build -t synchro/synchro_nginx_ap nginx

build-synchro:
docker build -t synchro/synchro_ap synchro

build-stashbox:
docker build -t synchro/stashbox_ap stashbox

build-redis:
docker build -t synchro/synchro_redis_ap redis

triton.env:
./setup.sh

# Start the composition on Triton
runtriton: triton.env
$(eval include triton.env)
$(eval export $(shell sed 's/=.*//' triton.env))
docker-compose -f triton-compose.yml up
68 changes: 68 additions & 0 deletions common-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Nginx as a load-balancing tier and reverse proxy, with caching and optional SSL termination
nginx:
image: synchro/synchro_nginx_ap:1.0.2
mem_limit: 128m
command: >
/bin/containerpilot
-config file:///etc/containerpilot/containerpilot.json
nginx -g "daemon off;"
restart: always
ports:
- 80
- 443
expose:
- 9090

# The Synchro microservice
synchro:
image: synchro/synchro_ap:1.5.14
mem_limit: 512m
restart: always
expose:
- 80
- 9090
environment:
- SYNCHRO_CONFIG_URL=stashbox/config/config.json
- SYNCHRO__PORT=80
- SYNCHRO__SESSIONSTORE_PACKAGE=synchro-api
- SYNCHRO__SESSIONSTORE_SERVICE=IoRedisSessionStore
- SYNCHRO__SESSIONSTORE__sentinels=true
- SYNCHRO__SESSIONSTORE__consulRetries=5
- SYNCHRO__SESSIONSTORE__consulDelayMs=5000
- SYNCHRO__LOG4JS_CONFIG__levels__synchro-ioredis-session=DEBUG

# StashBox
stashbox:
image: synchro/stashbox_ap:1.1.3
mem_limit: 128m
expose:
- 80

# redis
redis:
image: synchro/synchro_redis_ap:1.0.0
mem_limit: 128m
restart: always
expose:
- 6379
- 26379

# service discovery tier
consul:
image: progrium/consul:latest
mem_limit: 128m
command: -server -bootstrap -ui-dir /ui
restart: always
expose:
- 8500
dns:
- 127.0.0.1

# Prometheus is an open source performance monitoring tool
# it is included here for demo purposes and is not required
prometheus:
image: autopilotpattern/prometheus:latest
mem_limit: 1g
restart: always
ports:
- 9090
119 changes: 36 additions & 83 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,59 @@
# By default, the value of CONSUL will come from the .env file in this directory and will direct the
# services below to use the single consul instance directly. If you want to scale consul you should
# specify CONSUL_AGENT (with a truthy value) and you will also likely want to set the value of CONSUL
# to an appropriate host (for example, when deploying on Joyent, you would want to set it to a host name
# that Joyent CNS will resolve - see setup.sh in this directory).
# docker-compose.yml - Run services on local host
#

# Nginx as a load-balancing tier and reverse proxy, with caching and optional SSL termination
nginx:
image: synchro/synchro_nginx_ap:1.0.2
mem_limit: 128m
command: >
/bin/containerpilot
-config file:///etc/containerpilot/containerpilot.json
nginx -g "daemon off;"
restart: always
links:
- consul
- stashbox
extends:
file: common-services.yml
service: nginx
ports:
- 80
- 443
- 9090
labels:
# Joyent: Setting the CNS service name (not needed unless running on Joyent and using CNS)
- triton.cns.services=synchro
- 8080:80
links:
- consul
- stashbox
environment:
- CONSUL=${CONSUL}
- CONSUL_AGENT=${CONSUL_AGENT}
- CONSUL=consul

# The Synchro microservice
synchro:
image: synchro/synchro_ap:1.5.14
mem_limit: 512m
restart: always
extends:
file: common-services.yml
service: synchro
links:
- redis
- consul
- stashbox
expose:
- 80
ports:
- 9090
- redis
- consul
- stashbox
environment:
- SYNCHRO_CONFIG_URL=stashbox/config/config.json
- SYNCHRO__PORT=80
- SYNCHRO__SESSIONSTORE_PACKAGE=synchro-api
- SYNCHRO__SESSIONSTORE_SERVICE=IoRedisSessionStore
- SYNCHRO__SESSIONSTORE__sentinels=true
- SYNCHRO__SESSIONSTORE__consulRetries=5
- SYNCHRO__SESSIONSTORE__consulDelayMs=5000
- SYNCHRO__LOG4JS_CONFIG__levels__synchro-ioredis-session=DEBUG
- CONSUL=${CONSUL}
- CONSUL_AGENT=${CONSUL_AGENT}
- CONSUL=consul

# StashBox
stashbox:
image: synchro/stashbox_ap:1.1.3
mem_limit: 128m
expose:
- 80
extends:
file: common-services.yml
service: stashbox

# redis
redis:
image: synchro/synchro_redis_ap:1.0.0
mem_limit: 128m
restart: always
extends:
file: common-services.yml
service: redis
links:
- consul
expose:
- 6379
- 26379
labels:
- triton.cns.services=redis
- consul
environment:
- CONSUL=${CONSUL}
- CONSUL_AGENT=${CONSUL_AGENT}

# service discovery tier
consul:
image: progrium/consul:latest
mem_limit: 128m
command: -server -bootstrap -ui-dir /ui
restart: always
expose:
- 8500
dns:
- 127.0.0.1
labels:
- triton.cns.services=consul
- CONSUL=consul

# Prometheus is an open source performance monitoring tool
# it is included here for demo purposes and is not required
# Prometheus performance monitoring
prometheus:
image: autopilotpattern/prometheus:latest
mem_limit: 1g
restart: always
extends:
file: common-services.yml
service: prometheus
links:
- consul
ports:
- 9090
labels:
- triton.cns.services=prometheus
- consul
environment:
- CONSUL=${CONSUL}
- CONSUL_AGENT=${CONSUL_AGENT}
- CONSUL=consul

# service discovery tier
consul:
extends:
file: common-services.yml
service: consul
16 changes: 11 additions & 5 deletions setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ help() {
echo ' -p <project> use this name as the project prefix for docker-compose'
}


# default values which can be overriden by -f or -p flags
export COMPOSE_PROJECT_NAME=nginx
export COMPOSE_PROJECT_NAME=synchro
export COMPOSE_FILE=

# give the docker remote api more time before timeout
Expand Down Expand Up @@ -97,8 +96,15 @@ check() {
exit 1
fi

echo CONSUL=consul.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com > .env
echo CONSUL_AGENT=1 > .env
# Create and populate docker-compose .env file (this will overwrite any existing .env file)
echo '# Environment variables for Triton' > triton.env

echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >> triton.env
echo "TRITON_USER=${TRITON_USER}" >> triton.env
echo "TRITON_DC=${TRITON_DC}" >> triton.env
echo "TRITON_ACCOUNT=${TRITON_ACCOUNT}" >> triton.env

echo >> triton.env
}

# ---------------------------------------------------
Expand Down Expand Up @@ -127,4 +133,4 @@ do
done

# default behavior
check
check
67 changes: 67 additions & 0 deletions triton-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# triton-compose.yml - Run services on Triton
#

# Nginx as a load-balancing tier and reverse proxy, with caching and optional SSL termination
nginx:
extends:
file: common-services.yml
service: nginx
links:
- consul
- stashbox
labels:
- triton.cns.services=${COMPOSE_PROJECT_NAME}
environment:
- CONSUL_AGENT=1
- CONSUL=consul-${COMPOSE_PROJECT_NAME}.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com

# The Synchro microservice
synchro:
extends:
file: common-services.yml
service: synchro
links:
- redis
- consul
- stashbox
environment:
- CONSUL_AGENT=1
- CONSUL=consul-${COMPOSE_PROJECT_NAME}.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com

# StashBox
stashbox:
extends:
file: common-services.yml
service: stashbox

# redis
redis:
extends:
file: common-services.yml
service: redis
links:
- consul
environment:
- CONSUL_AGENT=1
- CONSUL=consul-${COMPOSE_PROJECT_NAME}.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com

# Prometheus performance monitoring
prometheus:
extends:
file: common-services.yml
service: prometheus
links:
- consul
labels:
- triton.cns.services=prometheus-${COMPOSE_PROJECT_NAME}
environment:
- CONSUL_AGENT=1
- CONSUL=consul-${COMPOSE_PROJECT_NAME}.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com

# service discovery tier
consul:
extends:
file: common-services.yml
service: consul
labels:
- triton.cns.services=consul-${COMPOSE_PROJECT_NAME}

0 comments on commit 067568a

Please sign in to comment.