Skip to content

Commit

Permalink
[CE-273] Add dev/production start options
Browse files Browse the repository at this point in the history
Use different compose file for start service depend on DEV
Set DEV=False as default value

Change-Id: Ide9cb92cd7039cf8ce5dc355fd363c5d7de7221e
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Feb 12, 2018
1 parent 7643555 commit bd6d527
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 27 deletions.
10 changes: 9 additions & 1 deletion .makerc/admin-dashboard → .makerc/operator-dashboard
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# SPDX-License-Identifier: Apache-2.0

# Theme name for admin dashboard basic/vue/react
THEME?=basic
STATIC_FOLDER?=themes\/${THEME}\/static
TEMPLATE_FOLDER?=themes\/${THEME}\/templates
# npm registry repo
NPM_REGISTRY?=https://registry.npmjs.org
# service running dev/production mode
DEV?=True
DEV?=False
# whether enable user active, if enable user must be active to use user dashboard
ENABLE_EMAIL_ACTIVE?=False

NPM_REGISTRY_REPLACE=$(subst $(SLASH),$(REPLACE_SLASH),$(NPM_REGISTRY))

ifeq (${DEV}, True)
DEPLOY_COMPOSE_FILE:=docker-compose-dev.yml
else
DEPLOY_COMPOSE_FILE:=docker-compose.yml
endif
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SLASH:=/
REPLACE_SLASH:=\/

-include .makerc/email
-include .makerc/admin-dashboard
-include .makerc/operator-dashboard
-include .makerc/user-dashboard

export ROOT_PATH = ${PWD}
Expand Down Expand Up @@ -203,11 +203,11 @@ initial-env: ##@Configuration Initial Configuration for dashboard
start: ##@Service Start service
@$(MAKE) $(START_OPTIONS)
echo "Start all services... docker images must exist local now, otherwise, run 'make setup-master first' !"
docker-compose up -d --no-recreate
docker-compose -f ${DEPLOY_COMPOSE_FILE} up -d --no-recreate

stop: ##@Service Stop service
echo "Stop all services..."
docker-compose stop
docker-compose -f ${DEPLOY_COMPOSE_FILE} stop
echo "Remove all services..."
docker-compose rm -f -a

Expand Down
152 changes: 152 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# This compose file will deploy the services, and bootup a mongo server.

# Copyright IBM Corp., All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Local `/opt/cello/mongo` will be used for the db storage.

# cello-nginx: proxy to access operator dashboard service, listen on 8080
# cello-operator-dashboard: dashboard service for operators
# cello-user-dashboard: user service of cello, listen on 8081
# engine: engine service of cello to provide RESTful APIs, listen on 80
# cello-mongo: mongo db

version: '3.2'
services:
# nginx as front end for the operator dashboard
nginx:
image: hyperledger/cello-nginx
hostname: cello-nginx
container_name: cello-nginx
restart: always
deploy:
resources:
limits:
cpus: '0.50'
memory: 2048M
reservations:
cpus: '0.10'
memory: 256M
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.default.conf
#- /opt/cello/nginx/log/:/var/log/nginx/
ports:
- "80:80"
- "8080:8080"
environment:
- BACKEND=cello-operator-dashboard
- PORT=8080
- USERNAME=admin
- PASSWORD=pass

# cello dashboard service for network operator
operator-dashboard:
image: hyperledger/cello-operator-dashboard
container_name: cello-operator-dashboard
hostname: cello-operator-dashboard
restart: unless-stopped
environment:
- MONGO_URL=mongodb://cello-mongo:27017
- MONGO_DB=dev
- DEBUG=True # in debug mode, service will auto-restart
- LOG_LEVEL=DEBUG # what level log will be output
- STATIC_FOLDER=$STATIC_FOLDER
- TEMPLATE_FOLDER=$TEMPLATE_FOLDER
- ENABLE_EMAIL_ACTIVE=$ENABLE_EMAIL_ACTIVE
expose:
- "8080"
volumes: # This should be removed in product env
- ./src:/app

#TODO: need to follow other images to put at dockerhub
user-dashboard:
image: hyperledger/cello-user-dashboard
container_name: cello-user-dashboard
hostname: cello-user-dashboard
links:
- mongo:dashboard_mongo
- dashboard_mongo
- operator-dashboard
ports:
- "8081:8080"
environment:
- SV_BaseURL=http://operator-dashboard:8080/api/
- RESTful_Server=operator-dashboard:8080
- RESTful_BaseURL=/api/
- DEBUG=node:*
- DEV=$DEV
- ENABLE_EMAIL_ACTIVE=$ENABLE_EMAIL_ACTIVE
- SMTP_SERVER=$SMTP_SERVER
- SMTP_PORT=$SMTP_PORT
- SMTP_AUTH_USERNAME=$SMTP_AUTH_USERNAME
- SMTP_AUTH_PASSWORD=$SMTP_AUTH_PASSWORD
- FROM_EMAIL=$FROM_EMAIL
- WEBROOT=$WEBROOT
- FABRIC_CFG_PATH=/etc/hyperledger/fabric
volumes:
- ./user-dashboard:/usr/app/src
- /opt/cello/baas:/opt/data
command: bash -c "cd /usr/app/src && [ "$DEV" = True ] && npm run dev || npm start"

# cello engine service
engine:
image: hyperledger/cello-engine
container_name: cello-engine
hostname: cello-engine
restart: unless-stopped
environment:
- MONGO_URL=mongodb://cello-mongo:27017
- MONGO_DB=dev
- DEBUG=True # in debug mode, service will auto-restart
- LOG_LEVEL=DEBUG # what level log will be output
expose:
- "80"
volumes: # This should be removed in product env
- ./src:/app

# cello watchdog service
watchdog:
image: hyperledger/cello-watchdog
container_name: cello-watchdog
hostname: cello-watchdog
restart: unless-stopped
environment:
- MONGO_URL=mongodb://cello-mongo:27017
- MONGO_DB=dev
- DEBUG=True # in debug mode, service will auto-restart
- LOG_LEVEL=DEBUG # what level log will be output
volumes: # This should be removed in product env
- ./src:/app

# mongo database, may use others in future
mongo:
image: hyperledger/cello-mongo
hostname: cello-mongo
container_name: cello-mongo
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.50'
memory: 2048M
reservations:
cpus: '0.10'
memory: 256M
ports:
#- "27017:27017" # use follow line instead in production env
- "127.0.0.1:27017:27017"
- "127.0.0.1:27018:27018"
environment:
- NO_USED=0
volumes:
- /opt/cello/mongo:/data/db

# TODO: we may use one mongo instance, that should be enough
dashboard_mongo:
image: hyperledger/cello-mongo
restart: unless-stopped
environment:
- NO_USED=0
volumes:
- /opt/cello/dashboard_mongo:/data/db
21 changes: 0 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ services:
reservations:
cpus: '0.10'
memory: 256M
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.default.conf
#- /opt/cello/nginx/log/:/var/log/nginx/
ports:
- "80:80"
- "8080:8080"
Expand All @@ -42,9 +39,6 @@ services:

# cello dashboard service for network operator
operator-dashboard:
#build: # Remove soon
# context: src
# dockerfile: Dockerfile-dashboard
image: hyperledger/cello-operator-dashboard
container_name: cello-operator-dashboard
hostname: cello-operator-dashboard
Expand All @@ -59,13 +53,9 @@ services:
- ENABLE_EMAIL_ACTIVE=$ENABLE_EMAIL_ACTIVE
expose:
- "8080"
volumes: # This should be removed in product env
- ./src:/app

#TODO: need to follow other images to put at dockerhub
user-dashboard:
#build: # Remove soon
# context: user-dashboard
image: hyperledger/cello-user-dashboard
container_name: cello-user-dashboard
hostname: cello-user-dashboard
Expand All @@ -90,15 +80,11 @@ services:
- WEBROOT=$WEBROOT
- FABRIC_CFG_PATH=/etc/hyperledger/fabric
volumes:
- ./user-dashboard:/usr/app/src
- /opt/cello/baas:/opt/data
command: bash -c "cd /usr/app/src && [ "$DEV" = True ] && npm run dev || npm start"

# cello engine service
engine:
#build:
# context: src
# dockerfile: Dockerfile-restserver # Remove soon
image: hyperledger/cello-engine
container_name: cello-engine
hostname: cello-engine
Expand All @@ -110,14 +96,9 @@ services:
- LOG_LEVEL=DEBUG # what level log will be output
expose:
- "80"
volumes: # This should be removed in product env
- ./src:/app

# cello watchdog service
watchdog:
#build: # Remove soon
# context: src
# dockerfile: Dockerfile-watchdog
image: hyperledger/cello-watchdog
container_name: cello-watchdog
hostname: cello-watchdog
Expand All @@ -127,8 +108,6 @@ services:
- MONGO_DB=dev
- DEBUG=True # in debug mode, service will auto-restart
- LOG_LEVEL=DEBUG # what level log will be output
volumes: # This should be removed in product env
- ./src:/app

# mongo database, may use others in future
mongo:
Expand Down
Loading

0 comments on commit bd6d527

Please sign in to comment.