1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 06:00:06 +02:00

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
############################################################################# #############################################################################
frontend: frontend:
image: joyent/copilot-frontend image: joyent/copilot-frontend:1.0.0
mem_limit: 512m mem_limit: 512m
links: links:
- consul:consul - consul:consul
@ -66,7 +66,7 @@ frontend:
# BACKEND # BACKEND
############################################################################# #############################################################################
api: api:
image: joyent/copilot-api image: joyent/copilot-api:1.0.0
mem_limit: 512m mem_limit: 512m
links: links:
- consul:consul - consul:consul
@ -83,7 +83,7 @@ api:
# Docker-compose wrapper # Docker-compose wrapper
# Create _env file from running ./setup.sh # Create _env file from running ./setup.sh
compose-api: compose-api:
image: joyent/copilot-compose image: joyent/copilot-compose:1.0.0
links: links:
- consul:consul - consul:consul
expose: expose:

View File

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

View File

@ -40,10 +40,11 @@ prometheus:
# This label selects the proper Joyent resource package # 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 # https://www.joyent.com/blog/optimizing-docker-on-triton#ram-cpu-and-disk-resources-for-your-containers
- com.joyent.package=g4-highcpu-1G - com.joyent.package=g4-highcpu-1G
environment:
- CONSUL_AGENT=1
env_file: env_file:
- _env - _env
environment:
- CONSUL_AGENT=1
rethinkdb: rethinkdb:
image: autopilotpattern/rethinkdb:2.3.5r1 image: autopilotpattern/rethinkdb:2.3.5r1
@ -62,7 +63,7 @@ rethinkdb:
# FRONTEND # FRONTEND
############################################################################# #############################################################################
frontend: frontend:
image: joyent/copilot-frontend image: joyent/copilot-frontend:1.0.0
mem_limit: 512m mem_limit: 512m
labels: labels:
- triton.cns.services=copilot - triton.cns.services=copilot
@ -73,28 +74,27 @@ frontend:
ports: ports:
- "80:80" - "80:80"
- "443:443" - "443:443"
restart: always
############################################################################# #############################################################################
# BACKEND # BACKEND
############################################################################# #############################################################################
api: api:
image: joyent/copilot-api image: joyent/copilot-api:1.0.0
mem_limit: 1g mem_limit: 1g
links: expose:
- rethinkdb:rethinkdb - 3000
env_file: env_file:
- _env - _env
environment: environment:
- PORT=3000 - PORT=3000
- RETHINK_HOST=rethinkdb restart: always
expose:
- 3000
# Docker-compose wrapper # Docker-compose wrapper
# Create _env file from running ./setup.sh # Create _env file from running ./setup.sh
compose-api: compose-api:
image: joyent/copilot-compose image: joyent/copilot-compose:1.0.0
expose: expose:
- 4242 - 4242
env_file: env_file:
@ -102,10 +102,15 @@ compose-api:
restart: always restart: always
rethinkdb: rethinkdb:
image: rethinkdb image: autopilotpattern/rethinkdb:2.3.5r1
restart: always restart: always
mem_limit: 1g mem_limit: 1g
env_file:
- _env
environment:
- CONSUL_AGENT=1
ports:
- 8080:8080
expose: expose:
- 28015 - 28015
- 29015 - 29015
- 8080