Skip to content

Commit

Permalink
Merge pull request #729 from PierreBrisorgueil/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
PierreBrisorgueil authored Apr 27, 2020
2 parents 6b500c0 + c3939ad commit 1030daa
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 155 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
69 changes: 12 additions & 57 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,17 @@
# Build:
# docker build -t meanjs/mean .
#
# Run:
# docker run -it meanjs/mean
#
# Compose:
# docker-compose up -d
FROM node:lts-slim

FROM ubuntu:latest
MAINTAINER WAOS Node
# Create app directory
WORKDIR /usr/src/app

# 80 = HTTP, 443 = HTTPS, 3000 = WAOS Node server, 35729 = livereload, 8080 = node-inspector
EXPOSE 80 443 3000 35729 8080

# Set development environment as default
ENV NODE_ENV development

# Install Utilities
RUN apt-get update -q \
&& apt-get install -yqq \
curl \
git \
ssh \
gcc \
make \
build-essential \
libkrb5-dev \
sudo \
apt-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install app dependencies
COPY package*.json ./
RUN npm install

# Install WAOS Node Prerequisites
RUN npm install --quiet -g gulp bower yo mocha karma-cli pm2 && npm cache clean
# Bundle app source
COPY . .

RUN mkdir -p /opt/waosNode/public/lib
WORKDIR /opt/waosNode

# 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
COPY package.json /opt/waosNode/package.json
RUN npm install --quiet && npm cache clean

# Install bower packages
COPY bower.json /opt/waosNode/bower.json
COPY .bowerrc /opt/waosNode/.bowerrc
RUN bower install --quiet --allow-root --config.interactive=false

COPY . /opt/waosNode
# Expose
EXPOSE 80 443 3000 35729 8080

# Run WAOS Node server
CMD npm install && npm start
# Command to run the executable
CMD [ "node", "server.js" ]
62 changes: 0 additions & 62 deletions Dockerfile-production

This file was deleted.

15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ Our stack node is actually in Beta.
| CI | [Travis CI](https://travis-ci.org/weareopensource/Node)
| Developer | [Coveralls](https://coveralls.io/github/weareopensource/Node) - [Code Climate](https://codeclimate.com/github/weareopensource/Node) - [Dependency status](https://david-dm.org/weareopensource/node) - [Dependabot](https://dependabot.com/) - [Snyk](https://snyk.io/test/github/weareopensource/node) <br> [standard-version](https://github.com/conventional-changelog/standard-version) - [commitlint](https://github.com/conventional-changelog/commitlint) - [commitizen](https://github.com/commitizen/cz-cli) - [waos-conventional-changelog](https://github.com/WeAreOpenSourceProjects/waos-conventional-changelog)
| Dependencies | [npm](https://www.npmjs.com)
| **Being released** |
| Deliver | Docker & Docker-compose
| **In reflexion** |
| Documentation | Swagger <br> Docco
| Developer | uses v8's builtin `debug` and `inspect` optionse
| Developer | uses v8's builtin `debug` and `inspect` options
| API | evolution & version guideline

## Features Overview
Expand Down Expand Up @@ -95,6 +94,18 @@ npm i
* commit : `npm run commit`
* release : `npm run release`

## Docker Way

### docker

* `docker build -t waosnode .`
* `docker run --env WAOS_NODE_db_uri=mongodb://host.docker.internal/WaosNodeDev WAOS_NODE_host=0.0.0.0 --rm -p 3000:3000 waosnod`

### docker-compose

* `docker build -t waosnode .`
* `docker-compose up`

### Configuration

The default configuration is : `config/defaults/development.js`
Expand Down
64 changes: 30 additions & 34 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
version: '2'
version: '3'

services:
web:

waosnode:
container_name: waosnode
image: waosnode:latest
restart: always
build: .
container_name: meanjs
ports:
- "3000:3000"
- "5858:5858"
- "8080:8080"
- "35729:35729"
environment:
- NODE_ENV=development
- DB_1_PORT_27017_TCP_ADDR=db
depends_on:
- db
volumes_from:
- web-data
web-data:
build: .
entrypoint: /bin/true
- 3000:3000
volumes:
- ./:/opt/mean.js
- /opt/mean.js/node_modules
- /opt/mean.js/public
- /opt/mean.js/uploads
db:
image: mongo:3.2
- waosnode:/data
networks:
- mongo
depends_on:
- mongo
environment:
- "WAOS_NODE_db_uri=mongodb://mongo:27017/WaosNodeDev"
- "WAOS_NODE_host=0.0.0.0"

mongo:
container_name: mongo
image: mongo:latest
restart: always
ports:
- "27017:27017"
volumes_from:
- db-data
db-data:
image: mongo:3.2
volumes:
- /data/db
- /var/lib/mongodb
- /var/log/mongodb
entrypoint: /bin/true
- mongo:/data
networks:
- mongo

networks:
mongo:
driver: bridge

volumes:
waosnode:
mongo:

0 comments on commit 1030daa

Please sign in to comment.