Skip to content

Commit

Permalink
Working on production
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lin committed Aug 13, 2019
1 parent 8115045 commit 84b99ea
Show file tree
Hide file tree
Showing 25 changed files with 185 additions and 156 deletions.
Empty file added .travis.yml
Empty file.
31 changes: 8 additions & 23 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
command: ["redis-server", "--appendonly", "yes"]
container_name: redis_db
networks:
- dashboard
- dashboard-dev
ports:
- 6379:6379
nginx:
Expand All @@ -19,7 +19,7 @@ services:
depends_on:
- redis_db
networks:
- dashboard
- dashboard-dev
user:
build:
dockerfile: docker-dev.dockerfile
Expand All @@ -36,7 +36,7 @@ services:
- 4999:4999
command: npm start
networks:
- dashboard
- dashboard-dev
prices:
build:
dockerfile: docker-dev.dockerfile
Expand All @@ -50,15 +50,12 @@ services:
environment:
- NODE_ENV=development
- REDIS_HOST_DEV=redis_db
- REDIS_PORT_DEV=6379
- AUTH_HOST_DEV=http://user
- AUTH_PORT_DEV=4999
- AUTH_VER_DEV=v1
ports:
- 5000:5000
command: npm start
networks:
- dashboard
- dashboard-dev
promotions:
build:
dockerfile: docker-dev.dockerfile
Expand All @@ -72,15 +69,12 @@ services:
environment:
- NODE_ENV=development
- REDIS_HOST_DEV=redis_db
- REDIS_PORT_DEV=6379
- AUTH_HOST_DEV=http://user
- AUTH_PORT_DEV=4999
- AUTH_VER_DEV=v1
ports:
- 5001:5001
command: npm start
networks:
- dashboard
- dashboard-dev
upgrade-rules:
build:
dockerfile: docker-dev.dockerfile
Expand All @@ -94,15 +88,12 @@ services:
environment:
- NODE_ENV=development
- REDIS_HOST_DEV=redis_db
- REDIS_PORT_DEV=6379
- AUTH_HOST_DEV=http://user
- AUTH_PORT_DEV=4999
- AUTH_VER_DEV=v1
ports:
- 5002:5002
command: npm start
networks:
- dashboard
- dashboard-dev
web:
build:
dockerfile: docker-dev.dockerfile
Expand All @@ -115,19 +106,13 @@ services:
- ./services/web/.env
environment:
- NODE_ENV=development
- API_HOST_PRICES=http://localhost
- API_HOST_PROMOTIONS=http://localhost
- API_HOST_UPGRADERULES=http://localhost
- API_PORT_PRICES=3050
- API_PORT_PROMOTIONS=3050
- API_PORT_UPGRADERULES=3050
- API_VER_PRICES=v1
- API_VER_PROMOTIONS=v1
- API_VER_UPGRADERULES=v1
ports:
- 8080:8080
command: npm run start:dev
networks:
- dashboard
- dashboard-dev
networks:
dashboard:
dashboard-dev:
81 changes: 0 additions & 81 deletions docker-compose-prod.yml

This file was deleted.

100 changes: 100 additions & 0 deletions docker-compose-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
version: "3"
services:
redis_db-stage:
image: "redis:alpine"
command: ["redis-server", "--appendonly", "yes"]
container_name: redis_db-stage
networks:
- dashboard-stage
nginx-stage:
restart: always
build:
dockerfile: Dockerfile
context: ./nginx
container_name: nginx-stage
ports:
- "3060:80"
depends_on:
- redis_db-stage
networks:
- dashboard-stage
user-stage:
build:
dockerfile: Dockerfile
context: ./services/user/
container_name: user-stage
env_file:
- ./services/user/.env
environment:
- NODE_ENV=production
ports:
- 4999:4999
command: npm run prod
networks:
- dashboard-stage
prices-stage:
build:
dockerfile: Dockerfile
context: ./services/prices/
container_name: prices-stage
env_file:
- ./services/prices/.env
environment:
- NODE_ENV=production
- REDIS_HOST_PROD=redis_db
- AUTH_HOST_PROD=http://user
ports:
- 5000:5000
command: npm run prod
networks:
- dashboard-stage
promotions-stage:
build:
dockerfile: Dockerfile
context: ./services/promotions/
container_name: promotions-stage
env_file:
- ./services/promotions/.env
environment:
- NODE_ENV=production
- REDIS_HOST_PROD=redis_db
- AUTH_HOST_PROD=http://user
ports:
- 5001:5001
command: npm run prod
networks:
- dashboard-stage
upgrade-rules-stage:
build:
dockerfile: Dockerfile
context: ./services/upgrade-rules/
container_name: upgrade-rules-stage
env_file:
- ./services/upgrade-rules/.env
environment:
- NODE_ENV=production
- REDIS_HOST_PROD=redis_db
- AUTH_HOST_PROD=http://user
ports:
- 5002:5002
command: npm run prod
networks:
- dashboard-stage
web-stage:
build:
dockerfile: Dockerfile
context: ./services/web/
container_name: web-stage
env_file:
- ./services/web/.env
environment:
- NODE_ENV=production
- API_PORT_PRICES=3060
- API_PORT_PROMOTIONS=3060
- API_PORT_UPGRADERULES=3060
ports:
- 3000:3000
networks:
- dashboard-stage
networks:
dashboard-stage:
2 changes: 2 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx
COPY ./default.conf /etc/nginx/conf.d/default.conf
17 changes: 5 additions & 12 deletions nginx/default-prod.conf → nginx/default.conf
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
upstream web {
server web:3000;
server web-stage:3000;
}

upstream user {
server user:4999;
server user-stage:4999;
}

upstream prices {
server prices:5000;
server prices-stage:5000;
}

upstream promotions {
server promotions:5001;
server promotions-stage:5001;
}

upstream upgrade-rules {
server upgrade-rules:5002;
server upgrade-rules-stage:5002;
}

server{
Expand All @@ -32,13 +32,6 @@ server{
proxy_pass http://web;
}

location /sockjs-node {
proxy_pass http://web;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_updrade;
proxy_set_header Connection "Upgrade";
}

location /v1/user {
rewrite /v1/user/(.*) /$1 break;
proxy_pass http://user;
Expand Down
2 changes: 0 additions & 2 deletions nginx/docker-prod.dockerfile

This file was deleted.

14 changes: 14 additions & 0 deletions services/prices/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/build
/node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
.DS_Store
.env
dump.rdb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ RUN chown -R app:app /home/prices/

USER app
WORKDIR /home/prices
COPY package*.json /home/prices/
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

EXPOSE 5000
Expand Down
2 changes: 1 addition & 1 deletion services/prices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --exec babel-node src/server.js",
"build": "babel src -d build",
"build": "babel ./src -d build",
"prod": "node build/server.js"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ RUN chown -R app:app /home/promotions/

USER app
WORKDIR /home/promotions
COPY package*.json /home/promotions/
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

EXPOSE 5001
Expand Down
4 changes: 2 additions & 2 deletions services/promotions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "user",
"version": "1.0.0",
"description": "promotions api as service",
"main": "server.js",
"main": "src/server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --exec babel-node src/server.js",
"build": "babel src -d build",
"build": "babel ./src -d build",
"prod": "node build/server.js"
},
"keywords": [
Expand Down
Loading

0 comments on commit 84b99ea

Please sign in to comment.