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

Commit 25bd40c

Browse files
FedeGlirantal
authored andcommitted
feat(docker): Add Dockerfile for production
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
1 parent 2066be6 commit 25bd40c

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

Dockerfile-production

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Build:
2+
# docker build -t meanjs/mean -f Dockerfile-production .
3+
#
4+
# Run:
5+
# docker run -it meanjs/mean
6+
#
7+
# Compose:
8+
# docker-compose -f docker-compose-production.yml up -d
9+
10+
FROM ubuntu:latest
11+
MAINTAINER MEAN.JS
12+
13+
# Install Utilities
14+
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
15+
16+
# Install gem sass for grunt-contrib-sass
17+
RUN apt-get install -y ruby
18+
RUN gem install sass
19+
20+
# Install NodeJS
21+
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
22+
RUN sudo apt-get install -yq nodejs
23+
24+
# Install MEAN.JS Prerequisites
25+
RUN npm install --quiet -g grunt-cli gulp bower yo mocha karma-cli pm2
26+
27+
RUN mkdir /opt/mean.js
28+
RUN mkdir -p /opt/mean.js/public/lib
29+
WORKDIR /opt/mean.js
30+
31+
# Copies the local package.json file to the container
32+
# and utilities docker container cache to not needing to rebuild
33+
# and install node_modules/ everytime we build the docker, but only
34+
# when the local package.json file changes.
35+
# Install npm packages
36+
ADD package.json /opt/mean.js/package.json
37+
RUN npm install --quiet --production
38+
39+
# Install bower packages
40+
ADD bower.json /opt/mean.js/bower.json
41+
ADD .bowerrc /opt/mean.js/.bowerrc
42+
RUN bower install --quiet --allow-root --config.interactive=false
43+
44+
# Share local directory on the docker container
45+
ADD . /opt/mean.js
46+
47+
# Machine cleanup
48+
RUN npm cache clean
49+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
50+
51+
# Set development environment as default
52+
ENV NODE_ENV production
53+
54+
# Ports generic
55+
EXPOSE 80:80
56+
EXPOSE 443:443
57+
58+
# Port 3000 for MEAN.JS server
59+
EXPOSE 3000:3000
60+
61+
# Port 35729 for livereload
62+
EXPOSE 35729:35729
63+
64+
# Run MEAN.JS server
65+
CMD ["npm","run-script","start:prod"]

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,21 @@ $
203203
$ 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
204204
```
205205

206+
### Production deploy with Docker
207+
208+
* Production deployment with compose:
209+
```bash
210+
$ docker-compose -f docker-compose-production.yml up -d
211+
```
212+
213+
* Production deployment with just Docker:
214+
```bash
215+
$ docker build -t mean -f Dockerfile-production .
216+
$ docker run -p 27017:27017 -d --name db mongo
217+
$ docker run -p 3000:3000 --link db:db_1 mean
218+
$
219+
```
220+
206221
## Getting Started With MEAN.JS
207222
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).
208223
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.

docker-compose-production.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: '2'
2+
services:
3+
web:
4+
restart: always
5+
build:
6+
context: .
7+
dockerfile: Dockerfile-production
8+
container_name: meanjs
9+
ports:
10+
- "8443:8443"
11+
environment:
12+
- NODE_ENV=production
13+
- DB_1_PORT_27017_TCP_ADDR=db
14+
depends_on:
15+
- db
16+
volumes_from:
17+
- web-data
18+
web-data:
19+
build:
20+
context: .
21+
dockerfile: Dockerfile-production
22+
entrypoint: /bin/true
23+
volumes:
24+
- /opt/mean.js
25+
- /opt/mean.js/node_modules
26+
- /opt/mean.js/public
27+
- /opt/mean.js/uploads
28+
db:
29+
image: mongo:3.2
30+
restart: always
31+
volumes_from:
32+
- db-data
33+
db-data:
34+
image: mongo:3.2
35+
volumes:
36+
- /data/db
37+
- /var/lib/mongodb
38+
- /var/log/mongodb
39+
entrypoint: /bin/true
40+

0 commit comments

Comments
 (0)