From 636a02d04d347da9800d4396b855ad2066f596a5 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Tue, 23 Jan 2018 17:00:29 +0000 Subject: [PATCH] Created docker file --- .dockerignore | 5 +++++ Dockerfile | 19 +++++++++++++++++++ server.js | 6 ++---- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..75bbed2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +# Created by .ignore support plugin (hsz.mobi) +node_modules +npm-debug.log + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf84c74 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:carbon + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +# If you are building your code for production +# RUN npm install --only=production + +# Bundle app source +COPY . . + +EXPOSE 8080 +CMD [ "npm", "start" ] diff --git a/server.js b/server.js index 0f75481..53c63b4 100644 --- a/server.js +++ b/server.js @@ -11,7 +11,7 @@ const http = require('http'); const https = require('https'); const apicache = require('apicache'); -const port = process.env.PORT || 6566; +const port = process.env.PORT || 8080; logger.level = 'debug'; @@ -106,8 +106,6 @@ function getUrl (req, res) { http.request(options, responseHandler).end(); function responseHandler(response) { - console.log(`STATUS: ${response.statusCode}`); - console.log(`HEADERS: ${JSON.stringify(response.headers)}`); response.setEncoding('utf8'); if (response.statusCode === 302 || response.statusCode === 301) { body = []; @@ -119,7 +117,7 @@ function getUrl (req, res) { }; logger.debug('>> follow', response.headers.location, count); - // logger.debug(rUrl); + count++; if (rUrl.protocol === 'https:') https.request(rUrl, responseHandler).end();