From da40ee11e8b396e0cf7d32e847a25c0b8c7c5288 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 28 Jun 2017 17:11:04 -0500 Subject: [PATCH] chore: docker compose works with published images --- docker-compose.yml | 117 +++++++++++++++++----------- docker/api/Dockerfile | 4 +- docker/api/bootstrap-data.js | 2 +- docker/api/package.json | 4 +- docker/compose-api/Dockerfile | 4 +- docker/frontend/Dockerfile | 4 +- local-compose.yml | 53 +++++++------ packages/cp-gql-schema/package.json | 2 +- packages/portal-api/package.json | 2 +- setup.sh | 2 + 10 files changed, 112 insertions(+), 82 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index aedd3b28..550d7860 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,22 +6,26 @@ # turn this into an HA Consul raft. ############################################################################# consul: - image: autopilotpattern/consul:latest + image: autopilotpattern/consul:0.7.2-r0.8 command: > /usr/local/bin/containerpilot /bin/consul agent -server - -bootstrap-expect 3 - -config-dir=/etc/consul - -ui-dir /ui + -bootstrap-expect 1 + -config-dir=/etc/consul + -ui-dir /ui + # Change "-bootstrap" to "-bootstrap-expect 3", then scale to 3 or more to + # turn this into an HA Consul raft. restart: always mem_limit: 128m ports: + # As above, this port declaration should not be made for production. - 8500 + labels: + - triton.cns.services=copilot-consul dns: - 127.0.0.1 - labels: - - triton.cns.services=consul-$CIRCLE_BRANCH - - com.docker.swarm.affinities=["container!=~*"] + env_file: _env + ############################################################################# # PROMETHEUS @@ -31,57 +35,82 @@ consul: ############################################################################# prometheus: image: autopilotpattern/prometheus:latest + labels: + # This label sets the CNS name, Triton's automatic DNS + # Learn more at https://docs.joyent.com/public-cloud/network/cns + - triton.cns.services=prometheus + # This label selects the proper Joyent resource package + # https://www.joyent.com/blog/optimizing-docker-on-triton#ram-cpu-and-disk-resources-for-your-containers + - com.joyent.package=g4-highcpu-1G restart: always - mem_limit: 1g ports: + # You may not want these port declarations for production. Without them, Prometheus will only + # listen on the private network. This will also result in a public prometheus CNS record being created, + # in the triton.zone domain. - 9090 - labels: - - triton.cns.services=prometheus-$CIRCLE_BRANCH - - com.docker.swarm.affinities=["container!=~*prometheus*"] - -############################################################################# -# STYLEGUIDE -############################################################################# -styleguide: - image: quay.io/yldio/joyent-ui-toolkit:$CIRCLE_BRANCH - ports: - - 6060 - mem_limit: 512m - labels: - - triton.cns.services=styleguide-$CIRCLE_BRANCH - - com.docker.swarm.affinities=["container!=~*styleguide*"] + env_file: _env environment: - CONSUL_AGENT=1 - - PORT=6060 + dns: + - 127.0.0.1 ############################################################################# # FRONTEND ############################################################################# -cp-frontend: - image: quay.io/yldio/joyent-cp-frontend:$CIRCLE_BRANCH - mem_limit: 512m - labels: - - triton.cns.services=cp-frontend-$CIRCLE_BRANCH - - com.docker.swarm.affinities=["container!=~*cp-frontend*"] +frontend: + image: d0cker/copilot-frontend environment: - - CONSUL_AGENT=1 - - PORT=3069 - - REACT_APP_GQL_HOSTNAME=gql-mock-server-$CIRCLE_BRANCH.svc.f4b20699-b323-4452-9091-977895896da6.eu-ams-1.triton.zone - - REACT_APP_GQL_PORT=3000 + - PORT=8080 + - REACT_APP_GQL_PORT=80 + expose: + - 8080 + restart: always + +traefik: + image: d0cker/traefik + labels: + - triton.cns.services=copilot ports: - - 3069 + - 80 + - 8080 + restart: always + ############################################################################# # BACKEND ############################################################################# -gql-mock-server: - image: quay.io/yldio/joyent-cp-gql-mock-server:$CIRCLE_BRANCH - mem_limit: 512m - labels: - - triton.cns.services=gql-mock-server-$CIRCLE_BRANCH - - com.docker.swarm.affinities=["container!=~*gql-mock-server*"] +api: + image: d0cker/copilot-api + links: + - rethinkdb:rethinkdb + env_file: + - _env environment: - - CONSUL_AGENT=1 - - PORT=3000 + - PORT=8080 + - RETHINK_HOST=rethinkdb + expose: + - 8080 + restart: always + +# Docker-compose wrapper +# Create _env file from running ./setup.sh +composeapi: + image: d0cker/compose-api + expose: + - 4242 + env_file: + - _env + restart: always + +rethinkdb: + image: rethinkdb + restart: always + mem_limit: 1g + # You may not want these port declarations for production. It ports: - - 3000 + - 8080 + expose: + - 28015 + - 29015 + labels: + - triton.cns.services=copilot-rethinkdb diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile index a15203e4..1baeb904 100644 --- a/docker/api/Dockerfile +++ b/docker/api/Dockerfile @@ -17,8 +17,8 @@ RUN curl --retry 7 --fail -vo /tmp/consul.zip "https://releases.hashicorp.com/co && mkdir /config # Install ContainerPilot -ENV CP_SHA1 d06e289e6e0ca82156d77cea36ff0f0246fcca60 -ENV CONTAINERPILOT_VERSION 3.1.0 +ENV CP_SHA1 1f159207c7dc2b622f693754f6dda77c82a88263 +ENV CONTAINERPILOT_VERSION 3.1.1 RUN curl -Lo /tmp/containerpilot.tar.gz "https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VERSION}/containerpilot-${CONTAINERPILOT_VERSION}.tar.gz" \ && echo "${CP_SHA1} /tmp/containerpilot.tar.gz" | sha1sum -c \ && tar zxf /tmp/containerpilot.tar.gz -C /bin \ diff --git a/docker/api/bootstrap-data.js b/docker/api/bootstrap-data.js index 32419b93..21533f84 100644 --- a/docker/api/bootstrap-data.js +++ b/docker/api/bootstrap-data.js @@ -1,6 +1,6 @@ 'use strict'; -const Data = require('portal-data'); +const Data = require('portal-api/lib/data'); const ifError = function (err) { diff --git a/docker/api/package.json b/docker/api/package.json index 2213a9b7..fb2b80ed 100644 --- a/docker/api/package.json +++ b/docker/api/package.json @@ -19,9 +19,9 @@ "hapi": "^16.1.0", "hoek": "^4.1.1", "joi": "^10.6.0", - "joyent-cp-gql-schema": "^1.0.4", + "joyent-cp-gql-schema": "^1.2.0", "piloted": "^3.1.1", - "portal-api": "^1.1.0", + "portal-api": "^1.2.0", "toppsy": "^1.1.0" } } diff --git a/docker/compose-api/Dockerfile b/docker/compose-api/Dockerfile index c4a8078e..66559c55 100644 --- a/docker/compose-api/Dockerfile +++ b/docker/compose-api/Dockerfile @@ -11,10 +11,10 @@ RUN export CONSUL_VERSION=0.7.0 \ && mkdir /config # Add Containerpilot and set its configuration -ENV CONTAINERPILOT_VERSION 3.1.0 +ENV CONTAINERPILOT_VERSION 3.1.1 ENV CONTAINERPILOT /etc/containerpilot.json -RUN export CONTAINERPILOT_CHECKSUM=d06e289e6e0ca82156d77cea36ff0f0246fcca60 \ +RUN export CONTAINERPILOT_CHECKSUM=1f159207c7dc2b622f693754f6dda77c82a88263 \ && export archive=containerpilot-${CONTAINERPILOT_VERSION}.tar.gz \ && curl -Lso /tmp/${archive} \ "https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VERSION}/${archive}" \ diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index 11649b43..6a0063a8 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -19,8 +19,8 @@ RUN curl --retry 7 --fail -vo /tmp/consul.zip "https://releases.hashicorp.com/co && mkdir /config # Install ContainerPilot -ENV CP_SHA1 d06e289e6e0ca82156d77cea36ff0f0246fcca60 -ENV CONTAINERPILOT_VERSION 3.1.0 +ENV CP_SHA1 1f159207c7dc2b622f693754f6dda77c82a88263 +ENV CONTAINERPILOT_VERSION 3.1.1 RUN curl -Lo /tmp/containerpilot.tar.gz "https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VERSION}/containerpilot-${CONTAINERPILOT_VERSION}.tar.gz" \ && echo "${CP_SHA1} /tmp/containerpilot.tar.gz" | sha1sum -c \ && tar zxf /tmp/containerpilot.tar.gz -C /bin \ diff --git a/local-compose.yml b/local-compose.yml index 7081c63e..2c095f0f 100644 --- a/local-compose.yml +++ b/local-compose.yml @@ -41,30 +41,6 @@ prometheus: dns: - 127.0.0.1 -# Docker-compose wrapper -# Create _env file from running ./setup.sh -compose-api: - build: ./docker/compose-api - links: - - consul:consul - expose: - - 4242 - env_file: - - _env - environment: - - CONSUL=consul - restart: always - -traefik: - image: d0cker/traefik - ports: - - "80:80" - - "8080:8080" - links: - - consul:consul - environment: - - CONSUL=consul - restart: always ############################################################################# # FRONTEND @@ -83,6 +59,18 @@ frontend: expose: - 3069 +traefik: + image: d0cker/traefik + ports: + - "80:80" + - "8080:8080" + links: + - consul:consul + environment: + - CONSUL=consul + restart: always + + ############################################################################# # BACKEND ############################################################################# @@ -101,9 +89,20 @@ api: expose: - 3000 -############################################################################# -# DATABASE -############################################################################# +# Docker-compose wrapper +# Create _env file from running ./setup.sh +compose-api: + build: docker/compose-api + links: + - consul:consul + expose: + - 4242 + env_file: + - _env + environment: + - CONSUL=consul + restart: always + rethinkdb: image: rethinkdb restart: always diff --git a/packages/cp-gql-schema/package.json b/packages/cp-gql-schema/package.json index 33b771a8..4b99730e 100644 --- a/packages/cp-gql-schema/package.json +++ b/packages/cp-gql-schema/package.json @@ -1,6 +1,6 @@ { "name": "joyent-cp-gql-schema", - "version": "1.1.0", + "version": "1.2.0", "license": "MPL-2.0", "repository": "github:yldio/joyent-portal", "main": "index.js", diff --git a/packages/portal-api/package.json b/packages/portal-api/package.json index 43140a58..59f0b8e8 100644 --- a/packages/portal-api/package.json +++ b/packages/portal-api/package.json @@ -1,6 +1,6 @@ { "name": "portal-api", - "version": "1.1.0", + "version": "1.2.0", "description": "", "main": "./lib/index.js", "scripts": { diff --git a/setup.sh b/setup.sh index b1792134..0f8aefe2 100755 --- a/setup.sh +++ b/setup.sh @@ -61,6 +61,7 @@ check() { TRITON_USER=$(triton profile get | awk -F": " '/account:/{print $2}') TRITON_DC=$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}') + TRITON_ACCOUNT=$(triton account get | awk -F": " '/id:/{print $2}') echo '# docker-compose-client for Triton' > _env TRITON_CREDS_PATH=/root/.triton @@ -75,6 +76,7 @@ check() { echo SDC_KEY_ID=${SDC_KEY_ID} >> _env echo TRITON_USER=${TRITON_USER} >> _env echo TRITON_DC=${TRITON_DC} >> _env + echo CONSUL=copilot-consul.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com >> _env echo TRITON_CA=$(cat "${DOCKER_CERT_PATH}"/ca.pem | tr '\n' '#') >> _env echo TRITON_CA_PATH=${TRITON_CREDS_PATH}/ca.pem >> _env echo TRITON_KEY=$(cat "${DOCKER_CERT_PATH}"/key.pem | tr '\n' '#') >> _env