diff --git a/Makefile b/Makefile index 9084f1d3..e7330680 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ ifeq ($(DOCKER_BASE), ) $(error "Architecture \"$(ARCH)\" is unsupported") endif -all: docker check +all: check build/docker/baseimage/$(DUMMY): build/docker/baseimage/$(DUMMY) build/docker/nginx/$(DUMMY): build/docker/nginx/$(DUMMY) @@ -118,7 +118,7 @@ build/docker/%/$(DUMMY): docker: $(patsubst %,build/docker/%/$(DUMMY),$(DOCKER_IMAGES)) -check: ##@Code Check code format +check: docker ##@Code Check code format tox @$(MAKE) test-case make start && sleep 10 && make stop @@ -164,7 +164,7 @@ initial-env: ##@Configuration Initial Configuration for dashboard $(SED) 's/\(DEV=\).*/\1${DEV}/' .env $(SED) 's/\(ROOT_PATH=\).*/\1${ROOT_PATH_REPLACE}/' .env -start: ##@Service Start service +start: docker ##@Service Start service @$(MAKE) $(START_OPTIONS) echo "Start all services..." docker-compose up -d --no-recreate diff --git a/baseimage/install.sh b/baseimage/install.sh index 45ed7d2e..5eba2110 100644 --- a/baseimage/install.sh +++ b/baseimage/install.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x # # Copyright IBM Corp. All Rights Reserved. # @@ -77,7 +78,12 @@ rm -f /tmp/node*.tar.gz # ---------------------------------------------------------------- # Install python3 and pip # ---------------------------------------------------------------- -apt-get -y install python3 +if [[ $ARCH = 'ppc64le' ]];then +apt-get install build-essential libssl-dev libffi-dev python3-dev libxslt-dev python3 -y +else +apt-get install python3 -y +fi + update-alternatives --install /usr/bin/python python /usr/bin/python3 10 cd /tmp wget https://bootstrap.pypa.io/get-pip.py @@ -87,4 +93,5 @@ rm get-pip.py # ---------------------------------------------------------------- # Install nginx # ---------------------------------------------------------------- -apt-get install nginx -y +groupadd -r nginx && useradd -r -g nginx nginx +apt-get install nginx apache2-utils -y diff --git a/config/nginx/Dockerfile.in b/config/nginx/Dockerfile.in index 2e15db01..239022a2 100644 --- a/config/nginx/Dockerfile.in +++ b/config/nginx/Dockerfile.in @@ -1,7 +1,10 @@ FROM _NS_/cello-baseimage:_TAG_ + +COPY nginx/ /tmp/ + +RUN cp /tmp/nginx.default.conf /etc/nginx/nginx.default.conf + RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log -EXPOSE 80 443 - -CMD ["nginx", "-g", "daemon off;"] +CMD ["/bin/bash", "/tmp/docker-entrypoint.sh"] diff --git a/docker-compose-build-js.yml b/docker-compose-build-js.yml index c5f2c503..ed011d6b 100644 --- a/docker-compose-build-js.yml +++ b/docker-compose-build-js.yml @@ -14,7 +14,7 @@ version: '2' services: # cello dashboard service build-js: - image: node + image: hyperledger/cello-baseimage volumes: # This should be removed in product env - ./src/$STATIC_FOLDER:/app - ./src/$TEMPLATE_FOLDER:/app/templates diff --git a/docker-compose-npm-install.yml b/docker-compose-npm-install.yml index 8e66a2c5..8dfd5cdf 100644 --- a/docker-compose-npm-install.yml +++ b/docker-compose-npm-install.yml @@ -14,7 +14,7 @@ version: '2' services: # cello dashboard service npm-install: - image: node + image: hyperledger/cello-baseimage volumes: # This should be removed in product env - ./src/$STATIC_FOLDER:/app environment: diff --git a/docker-compose-watch-mode.yml b/docker-compose-watch-mode.yml index 3bf938a6..07b571bb 100644 --- a/docker-compose-watch-mode.yml +++ b/docker-compose-watch-mode.yml @@ -14,7 +14,7 @@ version: '2' services: # cello dashboard service watch-mode: - image: node + image: hyperledger/cello-baseimage container_name: watch-mode volumes: # This should be removed in product env - ./src/themes/react/static:/app diff --git a/docker-compose.yml b/docker-compose.yml index ea5ae9b4..d8f56c5b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: build: context: src dockerfile: Dockerfile-dashboard - image: cello-dashboard + image: hyperledger/cello-dashboard container_name: dashboard hostname: cello-dashboard restart: unless-stopped @@ -38,7 +38,7 @@ services: build: context: src dockerfile: Dockerfile-restserver - image: cello-restserver + image: hyperledger/cello-restserver container_name: restserver hostname: cello-restserver restart: unless-stopped @@ -57,7 +57,7 @@ services: build: context: src dockerfile: Dockerfile-watchdog - image: cello-watchdog + image: hyperledger/cello-watchdog container_name: watchdog hostname: cello-watchdog restart: unless-stopped @@ -71,7 +71,7 @@ services: # mongo database, may use others in future mongo: - image: mongo:3.2 + image: hyperledger/cello-mongo hostname: mongo container_name: mongo restart: unless-stopped @@ -87,7 +87,7 @@ services: # nginx to forward front request, may split it out in future nginx: - image: yeasy/nginx + image: hyperledger/cello-nginx hostname: nginx container_name: nginx restart: always @@ -107,7 +107,7 @@ services: user-dashboard: build: context: user-dashboard - image: cello-user-dashboard + image: hyperledger/cello-user-dashboard container_name: user-dashboard links: - mongo:dashboard_mongo diff --git a/nginx/docker-entrypoint.sh b/nginx/docker-entrypoint.sh new file mode 100644 index 00000000..f388fdde --- /dev/null +++ b/nginx/docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Based this file on https://github.com/yeasy/docker-nginx/blob/master/docker-entrypoint.sh + +set -e +backend="${BACKEND:-localhost}" +port="${PORT:-80}" +username="${USERNAME:-user}" +password="${PASSWORD:-pass}" + +htpasswd -c -b /etc/nginx/.htpasswd "$username" "$password" + +sed "s/BACKEND/$backend/; s/PORT/$port/" /etc/nginx/nginx.default.conf > /etc/nginx/nginx.conf + +nginx -c /etc/nginx/nginx.conf diff --git a/nginx/nginx.default.conf b/nginx/nginx.default.conf new file mode 100644 index 00000000..aa1e9699 --- /dev/null +++ b/nginx/nginx.default.conf @@ -0,0 +1,64 @@ +# This file should be put under /etc/nginx/conf.d/ +# Or place as /etc/nginx/nginx.conf + +user nginx; +worker_processes auto; +daemon off; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + server_tokens off; + + sendfile on; + tcp_nopush on; + + keepalive_timeout 60; + tcp_nodelay on; + client_body_timeout 15; + + gzip on; + gzip_vary on; + gzip_min_length 1k; + + upstream backend { + server BACKEND:PORT; + } + + server { + listen 80; + + location / { + if ($request_method !~ ^(GET|DELETE|POST|PUT)$ ) { + return 444; + } + auth_basic "Login"; + auth_basic_user_file /etc/nginx/.htpasswd; + proxy_pass http://backend; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Real-IP $remote_addr; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + include /etc/nginx/conf.d/*.conf; +} diff --git a/scripts/master_node/setup.sh b/scripts/master_node/setup.sh index 908f4962..d0761ca0 100755 --- a/scripts/master_node/setup.sh +++ b/scripts/master_node/setup.sh @@ -100,7 +100,7 @@ command -v docker-compose >/dev/null 2>&1 || { echo_r >&2 "No docker-compose fou && echo_r "Warn: existing containers may cause unpredictable failure, suggest to clean them using docker rm" echo_b "Download dependent Images..." -bash ./download_images.sh +#bash ./download_images.sh echo_b "Checking local mounted database path ${DB_DIR}..." [ ! -d ${DB_DIR} ] \ diff --git a/src/Dockerfile-dashboard b/src/Dockerfile-dashboard index b9ef0707..f986b4d9 100644 --- a/src/Dockerfile-dashboard +++ b/src/Dockerfile-dashboard @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -FROM python:3.5 +FROM hyperledger/cello-baseimage MAINTAINER Baohua Yang <"baohyang@cn.ibm.com"> ENV TZ Asia/Shanghai diff --git a/src/Dockerfile-restserver b/src/Dockerfile-restserver index 2ee1da2d..cb52cc0c 100644 --- a/src/Dockerfile-restserver +++ b/src/Dockerfile-restserver @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -FROM python:3.5 +FROM hyperledger/cello-baseimage MAINTAINER Baohua Yang <"baohyang@cn.ibm.com"> ENV TZ Asia/Shanghai diff --git a/src/Dockerfile-watchdog b/src/Dockerfile-watchdog index 6f7deb94..562085fd 100644 --- a/src/Dockerfile-watchdog +++ b/src/Dockerfile-watchdog @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -FROM python:3.5 +FROM hyperledger/cello-baseimage MAINTAINER Baohua Yang <"baohyang@cn.ibm.com"> ENV TZ Asia/Shanghai @@ -14,4 +14,4 @@ RUN pip install -r requirements.txt COPY . /app # use this in development -CMD ["python", "watchdog.py"] \ No newline at end of file +CMD ["python", "watchdog.py"] diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 87ecf6d7..277e6fea 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -17,7 +17,7 @@ services: build: context: ../src dockerfile: Dockerfile-dashboard - image: cello-dashboard + image: hyperledger/cello-dashboard container_name: dashboard-test hostname: cello-dashboard environment: @@ -36,7 +36,7 @@ services: # mongo database, may use others in future mongo: - image: mongo:3.2 + image: hyperledger/cello-mongo hostname: mongo container_name: mongo-test mem_limit: 2048m diff --git a/user-dashboard/Dockerfile b/user-dashboard/Dockerfile index 9d173c60..2079ebfe 100644 --- a/user-dashboard/Dockerfile +++ b/user-dashboard/Dockerfile @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -FROM node +FROM hyperledger/cello-baseimage MAINTAINER li xu cheng "lixucheng@aliyun.com" RUN npm install -g requirejs RUN mkdir -p /usr/app/src @@ -14,4 +14,4 @@ RUN mv /usr/app/src/js /reactjs && \ cd /reactjs/home && npm install && npm run build && rm -rf node_modules && \ cd /usr/app/src && npm install && npm run build && npm cache clean --force EXPOSE 8080 -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "start"]