1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 23:30:05 +02:00

fix(portal-api): parse DOCKER_HOST for protocol, hostname, and port

This commit is contained in:
Sérgio Ramos 2017-06-28 11:02:41 +01:00 committed by Judit Greskovits
parent 15d689b0c2
commit 19635e7a0a

View File

@ -11,6 +11,7 @@ const Pack = require('./package');
const Portal = require('./lib'); const Portal = require('./lib');
const Path = require('path'); const Path = require('path');
const Fs = require('fs'); const Fs = require('fs');
const Url = require('url');
const server = new Hapi.Server(); const server = new Hapi.Server();
server.connection({ port: 3000 }); server.connection({ port: 3000 });
@ -31,13 +32,17 @@ const {
SDC_KEY_ID SDC_KEY_ID
} = process.env; } = process.env;
const DOCKER_HOST_URL = DOCKER_HOST ? Url.parse(DOCKER_HOST) : {};
const portalOptions = { const portalOptions = {
data: { data: {
db: { db: {
host: process.env.RETHINK_HOST || 'localhost' host: process.env.RETHINK_HOST || 'localhost'
}, },
docker: { docker: {
host: DOCKER_HOST, protocol: 'https',
host: DOCKER_HOST_URL.hostname,
port: DOCKER_HOST_URL.port,
ca: DOCKER_CERT_PATH ? ca: DOCKER_CERT_PATH ?
Fs.readFileSync(Path.join(DOCKER_CERT_PATH, 'ca.pem')) : Fs.readFileSync(Path.join(DOCKER_CERT_PATH, 'ca.pem')) :
undefined, undefined,
@ -46,8 +51,7 @@ const portalOptions = {
undefined, undefined,
key: DOCKER_CERT_PATH ? key: DOCKER_CERT_PATH ?
Fs.readFileSync(Path.join(DOCKER_CERT_PATH, 'key.pem')) : Fs.readFileSync(Path.join(DOCKER_CERT_PATH, 'key.pem')) :
undefined, undefined
timeout: DOCKER_CLIENT_TIMEOUT
} }
}, },
watch: { watch: {