diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..96dc98b1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM dockerfile/nodejs + +MAINTAINER Matthias Luebken, matthias@catalyst-zero.com + +WORKDIR /home/mean + +# Install Mean.JS Prerequisites +RUN npm install -g grunt-cli +RUN npm install -g bower + +# Install Mean.JS packages +ADD package.json /home/mean/package.json +RUN npm install + +# Manually trigger bower. Why doesnt this work via npm install? +ADD .bowerrc /home/mean/.bowerrc +ADD bower.json /home/mean/bower.json +RUN bower install --config.interactive=false --allow-root + +# Make everything available for start +ADD . /home/mean + +# currently only works for development +ENV NODE_ENV development + +# Port 3000 for server +# Port 35729 for livereload +EXPOSE 3000 35729 +CMD ["grunt"] \ No newline at end of file diff --git a/README.md b/README.md index 05ac4b3b..dec285d1 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,29 @@ Your application should run on the 3000 port so in your browser just go to [http That's it! your application should be running by now, to proceed with your development check the other sections in this documentation. If you encounter any problem try the Troubleshooting section. +## Development and deployment With Docker + +* Install [Docker](http://www.docker.com/) +* Install [Fig](https://github.com/orchardup/fig) + +* Local development and testing with fig: +```bash +$ fig up +``` + +* Local development and testing with just Docker: +```bash +$ docker build -t mean . +$ docker run -p 27017:27017 -d --name db mongo +$ docker run -p 3000:3000 --link db:db_1 mean +$ +``` + +* To enable live reload forward 35729 port and mount /app and /public as volumes: +```bash +$ docker run -p 3000:3000 -p 35729:35729 -v /Users/mdl/workspace/mean-stack/mean/public:/home/mean/public -v /Users/mdl/workspa/mean-stack/mean/app:/home/mean/app --link db:db_1 mean +``` + ## Getting Started With MEAN.JS You have your application running but there are a lot of stuff to understand, we recommend you'll go over the [Offical Documentation](http://meanjs.org/docs.html). In the docs we'll try to explain both general concepts of MEAN components and give you some guidelines to help you improve your development procees. We tried covering as many aspects as possible, and will keep update it by your request, you can also help us develop the documentation better by checking out the *gh-pages* branch of this repository. diff --git a/config/env/development.js b/config/env/development.js index 17470972..8f1c18b7 100644 --- a/config/env/development.js +++ b/config/env/development.js @@ -1,7 +1,9 @@ 'use strict'; +var DB_HOST = process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost'; + module.exports = { - db: 'mongodb://localhost/mean-dev', + db: 'mongodb://' + DB_HOST + '/mean-dev', app: { title: 'MEAN.JS - Development Environment' }, diff --git a/config/env/production.js b/config/env/production.js index 26c97d77..2de715fe 100644 --- a/config/env/production.js +++ b/config/env/production.js @@ -1,7 +1,9 @@ 'use strict'; +var DB_HOST = process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost'; + module.exports = { - db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://localhost/mean', + db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + DB_HOST + '/mean', assets: { lib: { css: [ diff --git a/config/env/test.js b/config/env/test.js index cc3f0aa4..03135e6c 100644 --- a/config/env/test.js +++ b/config/env/test.js @@ -1,7 +1,9 @@ 'use strict'; +var DB_HOST = process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost'; + module.exports = { - db: 'mongodb://localhost/mean-test', + db: 'mongodb://' + DB_HOST + '/mean-test', port: 3001, app: { title: 'MEAN.JS - Test Environment' diff --git a/fig.yml b/fig.yml new file mode 100644 index 00000000..4726a151 --- /dev/null +++ b/fig.yml @@ -0,0 +1,12 @@ +web: + build: . + links: + - db + ports: + - "3000:3000" + environment: + NODE_ENV: development +db: + image: mongo + ports: + - "27017:27017" \ No newline at end of file