diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..762cf0a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM tatsushid/tinycore-node:6.6 +ENV NODE_ENV production + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +ENV REGISTRY http://9.10.79.72:4873/ +# ENV REGISTRY http://apiconnect01.rchland.ibm.com:4873/ +COPY package.json /usr/src/app/ +RUN npm config set registry $REGISTRY \ + && npm install --production + +COPY . /usr/src/app + +EXPOSE 3000 + +CMD [ "npm", "start" ] diff --git a/abc b/abc deleted file mode 100644 index 8d1c8b6..0000000 --- a/abc +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/analytics.js b/lib/analytics.js index c40ff6a..5f07f04 100644 --- a/lib/analytics.js +++ b/lib/analytics.js @@ -247,14 +247,15 @@ function performHandshake() { port: process.env[env.APIMANAGER_PORT], catalog: process.env[env.APIMANAGER_CATALOG], }; - - utils.handshakeWithAPIm(apim, function(error, result) { - if (error) { - logger.error('not able to perform the handshake with APIM, error:', error); - } else { - clientID = result.clientID; - } - }); + if (apim.host) { + utils.handshakeWithAPIm(apim, function(error, result) { + if (error) { + logger.error('not able to perform the handshake with APIM, error:', error); + } else { + clientID = result.clientID; + } + }); + } } module.exports.mkPatch = mkPatch; diff --git a/lib/api-loader/index.js b/lib/api-loader/index.js index 22ea23a..9dfb0a8 100644 --- a/lib/api-loader/index.js +++ b/lib/api-loader/index.js @@ -20,6 +20,7 @@ var optimizedDataCache = lru({ max: 3 }); //data store address var dsHost = '127.0.0.1'; var dsPort; +var odPath = '/api/optimizedData'; /* * The "api-loader" middlware reads the optimizedData from the current snapshot @@ -32,6 +33,12 @@ module.exports = function createApiLoaderMiddleware(options) { return function(req, res, next) { logger.debug('api-loader entry'); dsPort = process.env.DATASTORE_PORT; + if (process.env.DATASTORE_HOST) { + dsHost = process.env.DATASTORE_HOST; + } + if (process.env.OPTIMIZED_PATH) { + odPath = process.env.OPTIMIZED_PATH; + } async.waterfall([ //get the current snapshot id @@ -112,7 +119,7 @@ function doOptimizedDataRequest(snapshotId) { protocol: 'http', hostname: dsHost, port: dsPort, - pathname: '/api/optimizedData', + pathname: odPath, query: { filter: JSON.stringify(queryfilter) } }; var queryurl = url.format(queryurlObj); diff --git a/lib/microgw.js b/lib/microgw.js index 2f5d7b3..5aed8c1 100644 --- a/lib/microgw.js +++ b/lib/microgw.js @@ -55,6 +55,9 @@ exports.start = function(port) { return new Promise(function(resolve, reject) { ds.start(process.env.NODE_ENV === 'production') .then(function(useHttps) { + if (process.env.DATASTORE_HOST) { + useHttps = true; + } port = port || process.env.PORT || (useHttps ? 443 : 80); logger.debug('starting gateway ', port); if (useHttps) { diff --git a/package.json b/package.json index 21fc284..2712524 100644 --- a/package.json +++ b/package.json @@ -122,8 +122,8 @@ "loopback-component-explorer": "^2.3.0", "loopback-connector-redis": "0.0.3", "lru-cache": "^4.0.0", - "microgateway-datastore": "strongloop/microgateway-datastore", - "microgateway-util": "strongloop/microgateway-util", + "microgateway-datastore": "^1.x", + "microgateway-util": "^1.x", "moment": "^2.11.2", "multer": "^1.1.0", "osenv": "^0.1.3",