Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
feat(docker): Add Dockerfile for production
Browse files Browse the repository at this point in the history
Add dockerfile and compose for production (#1438)
Add Dockerfile for production

Fixes #1431 Fixes #1435

* feat(deploy): Add docker-compose.yml for production

Add docker-compose.yml for production

Fixes #1435

* feat(deploy): Update documentation for deployment

Update documentation for production deployment

Fixes #1435
  • Loading branch information
FedeG authored and lirantal committed Aug 25, 2016
1 parent 2066be6 commit 25bd40c
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Dockerfile-production
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Build:
# docker build -t meanjs/mean -f Dockerfile-production .
#
# Run:
# docker run -it meanjs/mean
#
# Compose:
# docker-compose -f docker-compose-production.yml up -d

FROM ubuntu:latest
MAINTAINER MEAN.JS

# Install Utilities
RUN apt-get update -q && apt-get install -yqq aptitude git traceroute dnsutils tree tcpdump psmisc gcc make build-essential libfreetype6 libfontconfig libkrb5-dev curl sudo

# Install gem sass for grunt-contrib-sass
RUN apt-get install -y ruby
RUN gem install sass

# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs

# Install MEAN.JS Prerequisites
RUN npm install --quiet -g grunt-cli gulp bower yo mocha karma-cli pm2

RUN mkdir /opt/mean.js
RUN mkdir -p /opt/mean.js/public/lib
WORKDIR /opt/mean.js

# Copies the local package.json file to the container
# and utilities docker container cache to not needing to rebuild
# and install node_modules/ everytime we build the docker, but only
# when the local package.json file changes.
# Install npm packages
ADD package.json /opt/mean.js/package.json
RUN npm install --quiet --production

# Install bower packages
ADD bower.json /opt/mean.js/bower.json
ADD .bowerrc /opt/mean.js/.bowerrc
RUN bower install --quiet --allow-root --config.interactive=false

# Share local directory on the docker container
ADD . /opt/mean.js

# Machine cleanup
RUN npm cache clean
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set development environment as default
ENV NODE_ENV production

# Ports generic
EXPOSE 80:80
EXPOSE 443:443

# Port 3000 for MEAN.JS server
EXPOSE 3000:3000

# Port 35729 for livereload
EXPOSE 35729:35729

# Run MEAN.JS server
CMD ["npm","run-script","start:prod"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,21 @@ $
$ docker run -p 3000:3000 -p 35729:35729 -v /Users/mdl/workspace/mean-stack/mean/public:/home/mean/public -v /Users/mdl/workspace/mean-stack/mean/app:/home/mean/app --link db:db_1 mean
```

### Production deploy with Docker

* Production deployment with compose:
```bash
$ docker-compose -f docker-compose-production.yml up -d
```

* Production deployment with just Docker:
```bash
$ docker build -t mean -f Dockerfile-production .
$ docker run -p 27017:27017 -d --name db mongo
$ docker run -p 3000:3000 --link db:db_1 mean
$
```

## Getting Started With MEAN.JS
You have your application running, but there is a lot of stuff to understand. We recommend you go over the [Official 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 process. We tried covering as many aspects as possible, and will keep it updated by your request. You can also help us develop and improve the documentation by checking out the *gh-pages* branch of this repository.
Expand Down
40 changes: 40 additions & 0 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '2'
services:
web:
restart: always
build:
context: .
dockerfile: Dockerfile-production
container_name: meanjs
ports:
- "8443:8443"
environment:
- NODE_ENV=production
- DB_1_PORT_27017_TCP_ADDR=db
depends_on:
- db
volumes_from:
- web-data
web-data:
build:
context: .
dockerfile: Dockerfile-production
entrypoint: /bin/true
volumes:
- /opt/mean.js
- /opt/mean.js/node_modules
- /opt/mean.js/public
- /opt/mean.js/uploads
db:
image: mongo:3.2
restart: always
volumes_from:
- db-data
db-data:
image: mongo:3.2
volumes:
- /data/db
- /var/lib/mongodb
- /var/log/mongodb
entrypoint: /bin/true

0 comments on commit 25bd40c

Please sign in to comment.