feat: support latest images

This commit is contained in:
geek 2017-08-30 16:52:33 -05:00 committed by Sérgio Ramos
parent edcf2f3fa5
commit e39e425db0
3 changed files with 47 additions and 33 deletions

View File

@ -46,7 +46,7 @@ prometheus:
# FRONTEND
#############################################################################
frontend:
image: joyent/copilot-frontend
image: joyent/copilot-frontend:1.0.0
mem_limit: 512m
links:
- consul:consul
@ -66,7 +66,7 @@ frontend:
# BACKEND
#############################################################################
api:
image: joyent/copilot-api
image: joyent/copilot-api:1.0.0
mem_limit: 512m
links:
- consul:consul
@ -83,7 +83,7 @@ api:
# Docker-compose wrapper
# Create _env file from running ./setup.sh
compose-api:
image: joyent/copilot-compose
image: joyent/copilot-compose:1.0.0
links:
- consul:consul
expose:

View File

@ -8,17 +8,14 @@ const Triton = require('triton');
const Url = require('url');
let bootstrapped = false;
let timeoutId;
const loadConfig = function () {
const docker = Piloted.service('docker-compose-api');
const rethink = Piloted.service('rethinkdb');
if (docker && rethink && !bootstrapped) {
bootstrapped = true;
if (docker && rethink) {
bootstrap({ docker, rethink });
} else if (!bootstrapped && !timeoutId) {
} else if (!timeoutId) {
timeoutId = setTimeout(() => {
timeoutId = null;
Piloted.refresh();
@ -61,25 +58,40 @@ const bootstrap = function ({ docker, rethink }) {
const region = process.env.TRITON_DC || 'us-sw-1';
data.connect(err => {
handlerError(err);
if (err) {
console.error(err);
return;
}
data.createDatacenter({ region, name: region }, (err, datacenter) => {
handlerError(err);
if (err) {
console.error(err);
return;
}
Triton.createClient(
{
profile: settings.triton
},
(err, { cloudapi }) => {
handlerError(err);
if (err) {
console.error(err);
return;
}
cloudapi.getAccount((err, { firstName, lastName, email, login }) => {
handlerError(err);
if (err) {
console.error(err);
return;
}
data.createUser(
{ firstName, lastName, email, login },
(err, user) => {
handlerError(err);
if (err) {
console.error(err);
return;
}
data.createPortal(
{
@ -87,7 +99,11 @@ const bootstrap = function ({ docker, rethink }) {
datacenter
},
(err, portal) => {
handlerError(err);
if (err) {
console.error(err);
return;
}
console.log('data bootstrapped');
process.exit(0);
}
@ -101,11 +117,4 @@ const bootstrap = function ({ docker, rethink }) {
});
};
const handlerError = function (err) {
if (err) {
console.error(err);
process.exit(1);
}
};
loadConfig();

View File

@ -40,10 +40,11 @@ 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
environment:
- CONSUL_AGENT=1
env_file:
- _env
environment:
- CONSUL_AGENT=1
rethinkdb:
image: autopilotpattern/rethinkdb:2.3.5r1
@ -62,7 +63,7 @@ rethinkdb:
# FRONTEND
#############################################################################
frontend:
image: joyent/copilot-frontend
image: joyent/copilot-frontend:1.0.0
mem_limit: 512m
labels:
- triton.cns.services=copilot
@ -73,28 +74,27 @@ frontend:
ports:
- "80:80"
- "443:443"
restart: always
#############################################################################
# BACKEND
#############################################################################
api:
image: joyent/copilot-api
image: joyent/copilot-api:1.0.0
mem_limit: 1g
links:
- rethinkdb:rethinkdb
expose:
- 3000
env_file:
- _env
environment:
- PORT=3000
- RETHINK_HOST=rethinkdb
expose:
- 3000
restart: always
# Docker-compose wrapper
# Create _env file from running ./setup.sh
compose-api:
image: joyent/copilot-compose
image: joyent/copilot-compose:1.0.0
expose:
- 4242
env_file:
@ -102,10 +102,15 @@ compose-api:
restart: always
rethinkdb:
image: rethinkdb
image: autopilotpattern/rethinkdb:2.3.5r1
restart: always
mem_limit: 1g
env_file:
- _env
environment:
- CONSUL_AGENT=1
ports:
- 8080:8080
expose:
- 28015
- 29015
- 8080