From b35b42e0630152b2580faca78155719a0596137c Mon Sep 17 00:00:00 2001 From: Andrew Koroluk Date: Sun, 9 Oct 2016 17:21:32 -0400 Subject: [PATCH 1/2] feat(app): add Docker support --- templates/app/Dockerfile | 16 ++++++++++++++++ .../app/server/config/environment/production.js | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 templates/app/Dockerfile diff --git a/templates/app/Dockerfile b/templates/app/Dockerfile new file mode 100644 index 000000000..f101bafb8 --- /dev/null +++ b/templates/app/Dockerfile @@ -0,0 +1,16 @@ +FROM node:6 + +# RUN npm cache clean -f; npm install -g yo + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +ENV NODE_PATH=/usr/local/lib/node_modules/:/usr/local/lib NODE_ENV=production + +COPY *.json /usr/src/app/ +RUN npm install +COPY ./dist/ /usr/src/app/ + +CMD [ "npm", "start" ] + +EXPOSE 8080 diff --git a/templates/app/server/config/environment/production.js b/templates/app/server/config/environment/production.js index 96d5de11c..1e1de6dd9 100644 --- a/templates/app/server/config/environment/production.js +++ b/templates/app/server/config/environment/production.js @@ -1,6 +1,14 @@ 'use strict'; /*eslint no-process-env:0*/ +let mongoAddr; + +if(process.env.MONGO_PORT_27017_TCP_ADDR) { + mongoAddr = `mongodb://${process.env.MONGO_PORT_27017_TCP_ADDR}:${process.env.MONGO_PORT_27017_TCP_PORT}/<%= lodash.slugify(appname) %>`; +} else { + mongoAddr = 'mongodb://localhost/<%= lodash.slugify(appname) %>'; +} + // Production specific configuration // ================================= module.exports = { @@ -19,7 +27,7 @@ module.exports = { uri: process.env.MONGODB_URI || process.env.MONGOHQ_URL || process.env.OPENSHIFT_MONGODB_DB_URL + process.env.OPENSHIFT_APP_NAME - || 'mongodb://localhost/<%= lodash.slugify(appname) %>' + || mongoAddr }<% } if (filters.sequelize) { %>, sequelize: { From bd2b554bbaf7ea9255e9a5ed86d84a2c4c46918d Mon Sep 17 00:00:00 2001 From: Andrew Koroluk Date: Tue, 11 Oct 2016 16:07:40 -0400 Subject: [PATCH 2/2] fix(gen:test): add Dockerfile to expected files --- src/test/get-expected-files.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/get-expected-files.js b/src/test/get-expected-files.js index 70b4bfc9c..c950e9163 100644 --- a/src/test/get-expected-files.js +++ b/src/test/get-expected-files.js @@ -97,6 +97,7 @@ export function app(options) { '.gitignore', '.travis.yml', '.yo-rc.json', + 'Dockerfile', 'gulpfile.babel.js', 'package.json', 'karma.conf.js',