diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7f71b801e..b87458e83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/README.md b/README.md index 4a6293d6d..d3d7f34b4 100644 --- a/README.md +++ b/README.md @@ -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)
[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
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 @@ -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` diff --git a/docker-compose.yml b/docker-compose.yml index 5461f79fe..e9418699f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: \ No newline at end of file