Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): add Docker support #2290

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/test/get-expected-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function app(options) {
'.gitignore',
'.travis.yml',
'.yo-rc.json',
'Dockerfile',
'gulpfile.babel.js',
'package.json',
'karma.conf.js',
Expand Down
16 changes: 16 additions & 0 deletions templates/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion templates/app/server/config/environment/production.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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: {
Expand Down