Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate telemetry #18

Merged
merged 5 commits into from
Apr 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,27 @@ RUN cd /usr/local/lib/node_modules/Couch411 && \
echo '{ "allow_root": true }' > /root/.bowerrc && \
bower install

# generate a self-signed cert. We would terminate any SSL at the load balancer but
# Touchbase won't start without at least a self-signed cert installed.
RUN openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
-subj "/C=US/ST=None/L=None/O=None/CN=example.com"

# we use consul-template to re-write our config.json
RUN curl -Lo /tmp/consul_template_0.11.0_linux_amd64.zip https://github.com/hashicorp/consul-template/releases/download/v0.11.0/consul_template_0.11.0_linux_amd64.zip && \
unzip /tmp/consul_template_0.11.0_linux_amd64.zip && \
mv consul-template /usr/local/bin

# get Containerbuddy release
RUN export CB=containerbuddy-0.0.1-alpha &&\
mkdir -p /opt/containerbuddy && \
curl -Lo /tmp/${CB}.tar.gz \
https://github.com/joyent/containerbuddy/releases/download/0.0.1-alpha/${CB}.tar.gz && \
tar -xf /tmp/${CB}.tar.gz && \
mv /build/containerbuddy /opt/containerbuddy/
ENV CONTAINERBUDDY_VERSION 1.4.0-rc3
RUN export CB_SHA1=24a2babaff53e9829bcf4772cfe0462f08838a11 \
&& mkdir -p /opt/containerbuddy \
&& curl -Lso /tmp/containerbuddy.tar.gz \
"https://github.com/joyent/containerbuddy/releases/download/${CONTAINERBUDDY_VERSION}/containerbuddy-${CONTAINERBUDDY_VERSION}.tar.gz" \
&& echo "${CB_SHA1} /tmp/containerbuddy.tar.gz" | sha1sum -c \
&& tar zxf /tmp/containerbuddy.tar.gz -C /opt/containerbuddy \
&& rm /tmp/containerbuddy.tar.gz

# add Containerbuddy and configuration
COPY touchbase.json /opt/containerbuddy/
COPY update-config.sh /opt/containerbuddy/

# add our starting application configuration
COPY run-touchbase.sh /usr/local/bin/run-touchbase.sh
COPY config.json /usr/local/lib/node_modules/Couch411/config.json

# generate a self-signed cert. We would terminate any SSL at the load balancer but
# Touchbase won't start without at least a self-signed cert installed.
RUN openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
-subj "/C=US/ST=None/L=None/O=None/CN=example.com"
COPY sensor.sh /opt/containerbuddy/
42 changes: 0 additions & 42 deletions config.json

This file was deleted.

110 changes: 63 additions & 47 deletions docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,95 @@
# Consul as a service discovery tier
# Start with a single host which will bootstrap the cluster.
# In production we'll want to use an HA cluster.
consul:
image: progrium/consul:latest
command: >
-server
-bootstrap-expect 1
-ui-dir /ui
restart: always
mem_limit: 128m
ports:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
- "8500:8500"
expose:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
dns:
- 127.0.0.1
labels:
- triton.cns.services=tb-consul
- 127.0.0.1
command: -server -bootstrap -ui-dir /ui

# Manually bootstrap the first instance, then...
# Scale this tier and each additional container/instance will automatically

# The first instance will automatically bootstrap the Couchbase cluster.
# Scale this tier and each additional instance will automatically
# self-configure as a member of the cluster
couchbase:
image: autopilotpattern/couchbase:enterprise-4.0.0-r1
image: autopilotpattern/couchbase:enterprise-4.0.0-r2 # r3 TODO
restart: always
links:
- consul
mem_limit: 1g
ports:
- 8091
- 8092
- 8093
- 11207
- 11210
- 11211
- 18091
- 18092
- 8091
- 8092
- 8093
expose:
- 8091
- 8092
- 8093
- 11207
- 11210
- 11211
- 18091
- 18092
links:
- consul:consul
env_file: _env
environment:
- CONSUL_HOST=http://consul:8500
- COUCHBASE_SERVICE_NAME=couchbase
labels:
- triton.cns.services=tb-couchbase


# the main application
touchbase:
build: .
links:
- consul
restart: always
mem_limit: 128m
ports:
- 3000
restart: always
- 3000
links:
- consul:consul
env_file: _env
command: >
/opt/containerbuddy/containerbuddy
-config file:///opt/containerbuddy/touchbase.json
/usr/local/bin/run-touchbase.sh
labels:
- triton.cns.services=tb-touchbase
node /usr/local/lib/node_modules/Couch411/app.js


# Nginx as a load-balancing tier and reverse proxy
nginx:
build: nginx/
mem_limit: 512m
restart: always
mem_limit: 128m
ports:
- 80
- 80
expose:
- 80
- 80
- 9090
links:
- consul:consul
restart: always
- consul:consul
env_file: _env
environment:
- CONTAINERBUDDY=file:///opt/containerbuddy/nginx.json
command: >
/opt/containerbuddy/containerbuddy
-config file:///opt/containerbuddy/nginx.json
nginx -g "daemon off;"
labels:
- triton.cns.services=tb-nginx


# Prometheus server to gather telemetry
prometheus:
image: autopilotpattern/prometheus
mem_limit: 128g
restart: always
ports:
- "9090:9090"
expose:
- 9090
links:
- consul:consul
env_file: _env
environment:
- CONSUL=consul
89 changes: 49 additions & 40 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,84 @@
# Consul as a service discovery tier
# Start with a single host which will bootstrap the cluster.
# In production we'll want to use an HA cluster.
consul:
image: progrium/consul:latest
command: -server -bootstrap -ui-dir /ui
restart: always
mem_limit: 128m
ports:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
- 8500 # expose only Consul's UI on the public IP
dns:
- 127.0.0.1
- 127.0.0.1
labels:
- triton.cns.services=tb-consul
- triton.cns.services=tb-consul
command: -server -bootstrap -ui-dir /ui

# Manually bootstrap the first instance, then...
# Scale this tier and each additional container/instance will automatically

# The first instance will automatically bootstrap the Couchbase cluster.
# Scale this tier and each additional instance will automatically
# self-configure as a member of the cluster
couchbase:
image: autopilotpattern/couchbase:enterprise-4.0.0-r1
image: autopilotpattern/couchbase:enterprise-4.0.0-r3
restart: always
links:
- consul
mem_limit: 4g
mem_limit: 4096m
ports:
- 8091
- 8092
- 8093
- 11207
- 11210
- 11211
- 18091
- 18092
- 8091
- 8092
- 8093
links:
- consul:consul
env_file: _env
environment:
- CONSUL_HOST=http://consul:8500
- COUCHBASE_SERVICE_NAME=couchbase
labels:
- triton.cns.services=tb-couchbase
- triton.cns.services=tb-couchbase


# the main application
touchbase:
image: autopilotpattern/touchbase
links:
- consul
restart: always
mem_limit: 1g
ports:
- 3000
restart: always
- 3000
links:
- consul:consul
env_file: _env
labels:
- triton.cns.services=tb-touchbase
command: >
/opt/containerbuddy/containerbuddy
-config file:///opt/containerbuddy/touchbase.json
/usr/local/bin/run-touchbase.sh
labels:
- triton.cns.services=tb-touchbase
node /usr/local/lib/node_modules/Couch411/app.js


# Nginx as a load-balancing tier and reverse proxy
nginx:
image: autopilotpattern/touchbase-demo-nginx
restart: always
mem_limit: 512m
ports:
- 80
- 80
links:
- consul:consul
restart: always
- consul:consul
env_file: _env
environment:
- CONTAINERBUDDY=file:///opt/containerbuddy/nginx.json
- CONTAINERBUDDY=file:///opt/containerbuddy/nginx.json
labels:
- triton.cns.services=tb-nginx
command: >
/opt/containerbuddy/containerbuddy
nginx -g "daemon off;"


# Prometheus server to gather telemetry
prometheus:
image: autopilotpattern/prometheus
mem_limit: 1g
restart: always
labels:
- triton.cns.services=tb-nginx
- triton.cns.services=tb-prometheus
ports:
- 9090
links:
- consul:consul
env_file: _env
environment:
- CONSUL=consul
25 changes: 13 additions & 12 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# a minimal Nginx container including Containerbuddy and a simple virtulhost config
# a minimal Nginx container including containerbuddy and a simple virtulhost config
FROM nginx:latest

# install curl and jq
# install some tooling
RUN apt-get update && \
apt-get install -y \
curl \
bc \
unzip && \
rm -rf /var/lib/apt/lists/*

# we use consul-template to re-write our Nginx virtualhost config
RUN curl -Lo /tmp/consul_template_0.11.0_linux_amd64.zip https://github.com/hashicorp/consul-template/releases/download/v0.11.0/consul_template_0.11.0_linux_amd64.zip && \
unzip /tmp/consul_template_0.11.0_linux_amd64.zip && \
mv consul-template /bin

# get Containerbuddy release
RUN export CB=containerbuddy-0.0.1-alpha &&\
mkdir -p /opt/containerbuddy && \
curl -Lo /tmp/${CB}.tar.gz \
https://github.com/joyent/containerbuddy/releases/download/0.0.1-alpha/${CB}.tar.gz && \
tar -xf /tmp/${CB}.tar.gz && \
mv /build/containerbuddy /opt/containerbuddy/
ENV CONTAINERBUDDY_VERSION 1.4.0-rc3
RUN export CB_SHA1=24a2babaff53e9829bcf4772cfe0462f08838a11 \
&& mkdir -p /opt/containerbuddy \
&& curl -Lso /tmp/containerbuddy.tar.gz \
"https://github.com/joyent/containerbuddy/releases/download/${CONTAINERBUDDY_VERSION}/containerbuddy-${CONTAINERBUDDY_VERSION}.tar.gz" \
&& echo "${CB_SHA1} /tmp/containerbuddy.tar.gz" | sha1sum -c \
&& tar zxf /tmp/containerbuddy.tar.gz -C /opt/containerbuddy \
&& rm /tmp/containerbuddy.tar.gz

# add Containerbuddy and all our configuration
ADD opt/containerbuddy /opt/containerbuddy/
ADD etc/nginx/conf.d /etc/nginx/conf.d/
# Add our configuration files and scripts
COPY opt/containerbuddy /opt/containerbuddy/
Loading