Skip to content

Commit 1030daa

Browse files
Merge pull request #729 from PierreBrisorgueil/docker
Docker
2 parents 6b500c0 + c3939ad commit 1030daa

File tree

5 files changed

+56
-155
lines changed

5 files changed

+56
-155
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Dockerfile

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,17 @@
1-
# Build:
2-
# docker build -t meanjs/mean .
3-
#
4-
# Run:
5-
# docker run -it meanjs/mean
6-
#
7-
# Compose:
8-
# docker-compose up -d
1+
FROM node:lts-slim
92

10-
FROM ubuntu:latest
11-
MAINTAINER WAOS Node
3+
# Create app directory
4+
WORKDIR /usr/src/app
125

13-
# 80 = HTTP, 443 = HTTPS, 3000 = WAOS Node server, 35729 = livereload, 8080 = node-inspector
14-
EXPOSE 80 443 3000 35729 8080
15-
16-
# Set development environment as default
17-
ENV NODE_ENV development
18-
19-
# Install Utilities
20-
RUN apt-get update -q \
21-
&& apt-get install -yqq \
22-
curl \
23-
git \
24-
ssh \
25-
gcc \
26-
make \
27-
build-essential \
28-
libkrb5-dev \
29-
sudo \
30-
apt-utils \
31-
&& apt-get clean \
32-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
33-
34-
# Install nodejs
35-
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
36-
RUN sudo apt-get install -yq nodejs \
37-
&& apt-get clean \
38-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
6+
# Install app dependencies
7+
COPY package*.json ./
8+
RUN npm install
399

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

43-
RUN mkdir -p /opt/waosNode/public/lib
44-
WORKDIR /opt/waosNode
45-
46-
# Copies the local package.json file to the container
47-
# and utilities docker container cache to not needing to rebuild
48-
# and install node_modules/ everytime we build the docker, but only
49-
# when the local package.json file changes.
50-
# Install npm packages
51-
COPY package.json /opt/waosNode/package.json
52-
RUN npm install --quiet && npm cache clean
53-
54-
# Install bower packages
55-
COPY bower.json /opt/waosNode/bower.json
56-
COPY .bowerrc /opt/waosNode/.bowerrc
57-
RUN bower install --quiet --allow-root --config.interactive=false
58-
59-
COPY . /opt/waosNode
13+
# Expose
14+
EXPOSE 80 443 3000 35729 8080
6015

61-
# Run WAOS Node server
62-
CMD npm install && npm start
16+
# Command to run the executable
17+
CMD [ "node", "server.js" ]

Dockerfile-production

Lines changed: 0 additions & 62 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ Our stack node is actually in Beta.
4141
| CI | [Travis CI](https://travis-ci.org/weareopensource/Node)
4242
| 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)
4343
| Dependencies | [npm](https://www.npmjs.com)
44-
| **Being released** |
4544
| Deliver | Docker & Docker-compose
4645
| **In reflexion** |
4746
| Documentation | Swagger <br> Docco
48-
| Developer | uses v8's builtin `debug` and `inspect` optionse
47+
| Developer | uses v8's builtin `debug` and `inspect` options
4948
| API | evolution & version guideline
5049

5150
## Features Overview
@@ -95,6 +94,18 @@ npm i
9594
* commit : `npm run commit`
9695
* release : `npm run release`
9796

97+
## Docker Way
98+
99+
### docker
100+
101+
* `docker build -t waosnode .`
102+
* `docker run --env WAOS_NODE_db_uri=mongodb://host.docker.internal/WaosNodeDev WAOS_NODE_host=0.0.0.0 --rm -p 3000:3000 waosnod`
103+
104+
### docker-compose
105+
106+
* `docker build -t waosnode .`
107+
* `docker-compose up`
108+
98109
### Configuration
99110

100111
The default configuration is : `config/defaults/development.js`

docker-compose.yml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
1-
version: '2'
1+
version: '3'
2+
23
services:
3-
web:
4+
5+
waosnode:
6+
container_name: waosnode
7+
image: waosnode:latest
48
restart: always
5-
build: .
6-
container_name: meanjs
79
ports:
8-
- "3000:3000"
9-
- "5858:5858"
10-
- "8080:8080"
11-
- "35729:35729"
12-
environment:
13-
- NODE_ENV=development
14-
- DB_1_PORT_27017_TCP_ADDR=db
15-
depends_on:
16-
- db
17-
volumes_from:
18-
- web-data
19-
web-data:
20-
build: .
21-
entrypoint: /bin/true
10+
- 3000:3000
2211
volumes:
23-
- ./:/opt/mean.js
24-
- /opt/mean.js/node_modules
25-
- /opt/mean.js/public
26-
- /opt/mean.js/uploads
27-
db:
28-
image: mongo:3.2
12+
- waosnode:/data
13+
networks:
14+
- mongo
15+
depends_on:
16+
- mongo
17+
environment:
18+
- "WAOS_NODE_db_uri=mongodb://mongo:27017/WaosNodeDev"
19+
- "WAOS_NODE_host=0.0.0.0"
20+
21+
mongo:
22+
container_name: mongo
23+
image: mongo:latest
2924
restart: always
30-
ports:
31-
- "27017:27017"
32-
volumes_from:
33-
- db-data
34-
db-data:
35-
image: mongo:3.2
3625
volumes:
37-
- /data/db
38-
- /var/lib/mongodb
39-
- /var/log/mongodb
40-
entrypoint: /bin/true
26+
- mongo:/data
27+
networks:
28+
- mongo
29+
30+
networks:
31+
mongo:
32+
driver: bridge
33+
34+
volumes:
35+
waosnode:
36+
mongo:

0 commit comments

Comments
 (0)