This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|