diff --git a/.makerc/functions b/.makerc/functions index c07cf49f9..6181fced5 100644 --- a/.makerc/functions +++ b/.makerc/functions @@ -14,3 +14,13 @@ define build_docker_locally . ; @touch $@ ; endef + +define build_docker_hub + dir=$*; \ + IMG=hyperledger/$(2)-$$dir; \ + echo "Building $$IMG"; \ + docker build \ + -t $$IMG \ + -t $$IMG:x86_64-latest \ + build_image/dockerhub/latest/$(1)/$$dir +endef diff --git a/Makefile b/Makefile index 5d5b402fe..f5978cdfe 100755 --- a/Makefile +++ b/Makefile @@ -134,18 +134,21 @@ agent-docker-%: docker-clean: stop image-clean ##@Clean all existing images -DOCKERHUB_IMAGES = baseimage engine operator-dashboard user-dashboard watchdog ansible-agent parse-server - -dockerhub: $(patsubst %,dockerhub-%,$(DOCKERHUB_IMAGES)) ##@Building latest docker images as hosted in dockerhub - -dockerhub-%: ##@Building latest images with dockerhub materials, to valid them - dir=$*; \ - IMG=hyperledger/cello-$$dir; \ - echo "Building $$IMG"; \ - docker build \ - -t $$IMG \ - -t $$IMG:x86_64-latest \ - build_image/dockerhub/latest/$$dir +DOCKERHUB_COMMON_IMAGES = api-engine dashboard + +dockerhub-common: $(patsubst %,dockerhub-common-%,$(DOCKERHUB_COMMON_IMAGES)) ##@Building latest docker images as hosted in dockerhub + +dockerhub-common-%: ##@Building latest images with dockerhub materials, to valid them + $(call build_docker_hub,common,$(BASENAME)) + +DOCKERHUB_AGENT_IMAGES = ansible kubernetes + +dockerhub-agent: $(patsubst %,dockerhub-agent-%,$(DOCKERHUB_AGENT_IMAGES)) ##@Building latest docker images as hosted in dockerhub + +dockerhub-agent-%: ##@Building latest images with dockerhub materials, to valid them + $(call build_docker_hub,agent,$(AGENT_BASENAME)) + +dockerhub: dockerhub-common dockerhub-agent dockerhub-pull: ##@Pull service images from dockerhub cd scripts/master_node && bash download_images.sh diff --git a/build_image/dockerhub/latest/ansible-agent/Dockerfile b/build_image/dockerhub/latest/agent/ansible/Dockerfile similarity index 100% rename from build_image/dockerhub/latest/ansible-agent/Dockerfile rename to build_image/dockerhub/latest/agent/ansible/Dockerfile diff --git a/build_image/dockerhub/latest/agent/kubernetes/Dockerfile b/build_image/dockerhub/latest/agent/kubernetes/Dockerfile new file mode 100644 index 000000000..9ff318052 --- /dev/null +++ b/build_image/dockerhub/latest/agent/kubernetes/Dockerfile @@ -0,0 +1,22 @@ +FROM busybox as downloader + +RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/master.zip && \ + unzip master.zip + +FROM python:3.6 + +LABEL maintainer="github.com/hyperledger/cello" + +COPY --from=downloader /tmp/cello-master/src/agent/kubernetes-agent/requirements.txt / +RUN pip install -r /requirements.txt +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && \ + mv kubectl /usr/local/bin/kubectl + +COPY --from=downloader /tmp/cello-master/src/agent/kubernetes-agent/src /app + +WORKDIR /app + +ENV KUBECONFIG /app/.kube/config +ENV PYTHONPATH /app:$PATHONPATH + +CMD python main.py diff --git a/build_image/dockerhub/latest/baseimage/Dockerfile b/build_image/dockerhub/latest/baseimage/Dockerfile deleted file mode 100644 index 96c950433..000000000 --- a/build_image/dockerhub/latest/baseimage/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM busybox as downloader - -RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/master.zip && \ - unzip master.zip - -FROM python:3.6 - -LABEL maintainer="github.com/hyperledger/cello" - -WORKDIR /app - -COPY install.sh /tmp/ - -# Install necessary software -RUN cd /tmp/ && \ - bash install.sh && \ - rm -f /tmp/install.sh - -COPY --from=downloader /tmp/cello-master/src/operator-dashboard /app -RUN cd /app/ && \ - pip install -r requirements.txt diff --git a/build_image/dockerhub/latest/baseimage/install.sh b/build_image/dockerhub/latest/baseimage/install.sh deleted file mode 100644 index c83313932..000000000 --- a/build_image/dockerhub/latest/baseimage/install.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -x -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -# Based thie file on https://github.com/docker-library/mongo/blob/master/3.4/Dockerfile & -# https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/#install-mongodb-enterprise - -set -x \ - && apt-get update && apt-get install -y supervisor gettext-base && rm -rf /var/lib/apt/lists/* diff --git a/build_image/dockerhub/latest/common/api-engine/Dockerfile b/build_image/dockerhub/latest/common/api-engine/Dockerfile new file mode 100644 index 000000000..8cf194d43 --- /dev/null +++ b/build_image/dockerhub/latest/common/api-engine/Dockerfile @@ -0,0 +1,25 @@ +FROM busybox as downloader + +RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/master.zip && \ + unzip master.zip + +FROM python:3.6 + +LABEL maintainer="github.com/hyperledger/cello" + +RUN apt-get update && apt-get install -y gettext-base graphviz libgraphviz-dev && \ + apt-get autoclean && apt-get clean && apt-get autoremove && rm -rf /var/cache/apt/ +COPY --from=downloader /tmp/cello-master/src/api-engine/requirements.txt / +RUN cd / && \ + pip install -r requirements.txt + +COPY --from=downloader /tmp/cello-master/src/api-engine /var/www/server +COPY --from=downloader /tmp/cello-master/src/api-engine/docker/uwsgi/server.ini /etc/uwsgi/apps-enabled/ +COPY --from=downloader /tmp/cello-master/src/api-engine/docker/scripts /scripts +COPY --from=downloader /tmp/cello-master/build_image/docker/common/api-engine/entrypoint.sh / + +RUN cd /var/www/server/api_engine && cp settings.py.initial settings.py && cd .. && python manage.py collectstatic --noinput + +WORKDIR /var/www/server + +CMD bash /entrypoint.sh diff --git a/build_image/dockerhub/latest/common/dashboard/Dockerfile b/build_image/dockerhub/latest/common/dashboard/Dockerfile new file mode 100644 index 000000000..21c82cb54 --- /dev/null +++ b/build_image/dockerhub/latest/common/dashboard/Dockerfile @@ -0,0 +1,26 @@ +FROM busybox as downloader + +RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/master.zip && \ + unzip master.zip + +FROM circleci/node:latest-browsers as builder + +LABEL maintainer="github.com/hyperledger/cello" + +WORKDIR /usr/src/app/ +USER root +COPY --from=downloader /tmp/cello-master/src/dashboard/package.json ./ +RUN yarn +COPY --from=downloader /tmp/cello-master/src/dashboard ./ +RUN npm run build + +FROM nginx:1.15.12 + +COPY --from=builder /usr/src/app/dist /usr/share/nginx/html +COPY --from=downloader /tmp/cello-master/build_image/docker/common/dashboard/config-nginx.sh / +RUN chmod +x /config-nginx.sh +COPY --from=downloader /tmp/cello-master/build_image/docker/common/dashboard/default.conf.tmpl /etc/nginx/conf.d/default.conf.tmpl + +EXPOSE 80 + +CMD ["bash", "-c", "/config-nginx.sh && nginx -g 'daemon off;'"] diff --git a/build_image/dockerhub/latest/engine/Dockerfile b/build_image/dockerhub/latest/engine/Dockerfile deleted file mode 100644 index 59f6c1b59..000000000 --- a/build_image/dockerhub/latest/engine/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright IBM Corp, All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -FROM hyperledger/cello-baseimage:x86_64-latest - -# use this in development -CMD ["python", "restserver.py"] - -# use this in product -#CMD ["gunicorn", "-w", "128", "-b", "0.0.0.0:80", "restserver:app"] - diff --git a/build_image/dockerhub/latest/operator-dashboard/Dockerfile b/build_image/dockerhub/latest/operator-dashboard/Dockerfile deleted file mode 100644 index d9ced63a1..000000000 --- a/build_image/dockerhub/latest/operator-dashboard/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright IBM Corp, All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -FROM node:8.9 as build_js -MAINTAINER haitao yue "hightall@me.com" -RUN cd /tmp && git clone https://github.com/hyperledger/cello.git -RUN cp -r /tmp/cello/src/operator-dashboard/static /var/www -RUN cd /var/www/dashboard && npm install && npm run build - -FROM hyperledger/cello-baseimage:x86_64-latest - -COPY --from=build_js /var/www/dist /app/static/dist -COPY --from=build_js /tmp/cello/src/operator-dashboard/celery.conf /etc/supervisor/conf.d/ -CMD /etc/init.d/supervisor start && bash /app/init_client_secrets.sh && if [ "$DEBUG" = "True" ]; then python dashboard.py ; else gunicorn -w 1 --worker-class eventlet -b 0.0.0.0:8080 dashboard:app ;fi diff --git a/build_image/dockerhub/latest/parse-server/Dockerfile b/build_image/dockerhub/latest/parse-server/Dockerfile deleted file mode 100644 index 65fe6c422..000000000 --- a/build_image/dockerhub/latest/parse-server/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM busybox as downloader - -RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/master.zip && \ - unzip master.zip - -FROM parseplatform/parse-server:3.1.2 - -LABEL maintainer="github.com/hyperledger/cello" - -COPY --from=downloader /tmp/cello-master/src/parse-server/cloud /parse-server/cloud - -RUN cd cloud && npm install diff --git a/build_image/dockerhub/latest/user-dashboard/Dockerfile b/build_image/dockerhub/latest/user-dashboard/Dockerfile deleted file mode 100644 index 8a38a3886..000000000 --- a/build_image/dockerhub/latest/user-dashboard/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright IBM Corp, All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -FROM busybox as builder -ENV FABRIC_VERSION_1_0 1.0.5 -RUN cd /tmp && ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') && \ - echo $ARCH &&wget -c https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${FABRIC_VERSION_1_0}/hyperledger-fabric-${ARCH}-${FABRIC_VERSION_1_0}.tar.gz && \ - mkdir fabric-1.0 && tar -zxvf hyperledger-fabric-${ARCH}-${FABRIC_VERSION_1_0}.tar.gz -C fabric-1.0 -ENV FABRIC_VERSION_1_2 1.2.0 -RUN cd /tmp && ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') && \ - echo $ARCH &&wget -c https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${FABRIC_VERSION_1_2}/hyperledger-fabric-${ARCH}-${FABRIC_VERSION_1_2}.tar.gz && \ - mkdir fabric-1.2 && tar -zxvf hyperledger-fabric-${ARCH}-${FABRIC_VERSION_1_2}.tar.gz -C fabric-1.2 -RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/master.zip && unzip master.zip - -FROM node:8.9 -MAINTAINER haitao yue "hightall@me.com" -COPY --from=builder /tmp/cello-master/src/user-dashboard/src/package.json / -COPY --from=builder /tmp/cello-master/src/user-dashboard/src/yarn.lock / -COPY --from=builder /tmp/cello-master/src/user-dashboard/src/packages /packages -COPY --from=builder /tmp/cello-master/src/user-dashboard/src /var/www -COPY --from=builder /tmp/cello-master/src/user-dashboard/fabric/fabric-1.0 /etc/hyperledger/fabric-1.0 -COPY --from=builder /tmp/cello-master/src/user-dashboard/fabric/fabric-1.2 /etc/hyperledger/fabric-1.2 -COPY --from=builder /tmp/cello-master/src/user-dashboard/src/app/lib/fabric/fixtures/channel/v1.2/crypto-config /etc/hyperledger/fabric-1.2/crypto-config -RUN cd / && yarn install -g --verbose -RUN cd /packages/fabric-1.0 && yarn install -RUN cd /packages/fabric-1.2 && yarn install -ENV PATH ${PATH}:/node_modules/.bin -RUN cd /var/www && ln -sf /node_modules . && npm run build -WORKDIR /var/www -EXPOSE 8081 - -COPY --from=builder /tmp/fabric-1.0/bin/configtxgen /usr/local/bin/fabric-1.0/configtxgen -COPY --from=builder /tmp/fabric-1.2/bin/configtxgen /usr/local/bin/fabric-1.2/configtxgen -ENV FABRIC_CFG_PATH /etc/hyperledger/fabric-1.0 -ENV MONGO_PORT 27017 - -RUN sed -i 's/.\/ecdsa\/key.js/fabric-client\/lib\/impl\/ecdsa\/key.js/g' /packages/fabric-1.2/node_modules/fabric-ca-client/lib/impl/CryptoSuite_ECDSA_AES.js - -CMD ln -sf /node_modules . && npm run start diff --git a/build_image/dockerhub/latest/watchdog/Dockerfile b/build_image/dockerhub/latest/watchdog/Dockerfile deleted file mode 100644 index 8d67e5b94..000000000 --- a/build_image/dockerhub/latest/watchdog/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright IBM Corp, All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -FROM hyperledger/cello-baseimage:x86_64-latest - -# use this in development -CMD ["python", "watchdog.py"] \ No newline at end of file