Skip to content

Commit

Permalink
[CE-461] Refine dockerhub latest dockerfile
Browse files Browse the repository at this point in the history
Prepare dockerfile for version 0.9.0.
Remove fabric-initial docker image build.

Change-Id: I3e0518d53d7b02f1d58e8314d46801627c3ac245
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Sep 3, 2018
1 parent 6d3f819 commit fefe906
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 286 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ else
endif

# Docker images needed to run cello services
DOCKER_IMAGES = baseimage mongo engine operator-dashboard ansible-agent watchdog user-dashboard fabric-initial
DOCKER_IMAGES = baseimage mongo engine operator-dashboard ansible-agent watchdog user-dashboard
DUMMY = .$(IMG_TAG)

ifeq ($(DOCKER_BASE), )
Expand Down Expand Up @@ -152,7 +152,7 @@ docker-operator-dashboard: build/docker/operator-dashboard/$(DUMMY)

docker-clean: stop image-clean ##@Clean all existing images

DOCKERHUB_IMAGES = baseimage engine operator-dashboard user-dashboard watchdog ansible-agent fabric-initial
DOCKERHUB_IMAGES = baseimage engine operator-dashboard user-dashboard watchdog ansible-agent

dockerhub: $(patsubst %,dockerhub-%,$(DOCKERHUB_IMAGES)) ##@Building latest images with dockerhub materials, to valid them

Expand Down
19 changes: 9 additions & 10 deletions dockerhub/latest/baseimage/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM ubuntu:xenial
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"

Expand All @@ -11,12 +16,6 @@ RUN cd /tmp/ && \
bash install.sh && \
rm -f /tmp/install.sh

# Clone code and put cello/src/* under /app
RUN cd /tmp && \
git clone https://github.com/hyperledger/cello.git && \
cd /tmp/cello && \
git checkout master && \
cp -r /tmp/cello/src/* /app && \
cd /app/ && \
pip install -r requirements.txt && \
rm -rf /tmp/cello
COPY --from=downloader /tmp/cello-master/src /app
RUN cd /app/ && \
pip install -r requirements.txt
81 changes: 1 addition & 80 deletions dockerhub/latest/baseimage/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,5 @@ set -x
# 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

# ----------------------------------------------------------------
# Install mongo
# ----------------------------------------------------------------

groupadd -r mongodb && useradd -r -g mongodb mongodb

apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates jq numactl sudo\
&& rm -rf /var/lib/apt/lists/*

# grab gosu for easy step-down from root
export GOSU_VERSION=1.10

set -x \
&& apt-get update && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/* \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true

mkdir /docker-entrypoint-initdb.d

# Add GPG Keys & update apt sources

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

echo "deb [ arch=amd64,arm64,ppc64el,s390x ] http://repo.mongodb.com/apt/ubuntu xenial/mongodb-enterprise/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-enterprise.list

apt-get update

export MONGO_PACKAGE=mongodb-enterprise
# export MONGO_REPO=repo.mongodb.com
# export MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO}

export MONGO_MAJOR=3.4
export MONGO_VERSION=3.4.10

apt-get install -y \
${MONGO_PACKAGE}=$MONGO_VERSION \
${MONGO_PACKAGE}-server=$MONGO_VERSION \
${MONGO_PACKAGE}-shell=$MONGO_VERSION \
${MONGO_PACKAGE}-mongos=$MONGO_VERSION \
${MONGO_PACKAGE}-tools=$MONGO_VERSION

mkdir -p /data/db /data/configdb \
&& chown -R mongodb:mongodb /data/db /data/configdb

# ----------------------------------------------------------------
# Install NodeJS
# ----------------------------------------------------------------
NODE_VER=8.9.0

ARCH=`uname -m | sed 's|i686|x86|' | sed 's|x86_64|x64|'`
NODE_PKG=node-v$NODE_VER-linux-$ARCH.tar.gz
SRC_PATH=/tmp/$NODE_PKG

# First remove any prior packages downloaded in case of failure
cd /tmp
rm -f node*.tar.gz
wget --quiet https://nodejs.org/dist/v$NODE_VER/$NODE_PKG
cd /usr/local && sudo tar --strip-components 1 -xzf $SRC_PATH
rm -f /tmp/node*.tar.gz

# ----------------------------------------------------------------
# Install python3 and pip
# ----------------------------------------------------------------
if [[ $ARCH = 'ppc64le' ]];then
apt-get install build-essential libssl-dev libffi-dev python3-dev libxslt-dev python3 -y
else
apt-get install python3 git -y
fi

update-alternatives --install /usr/bin/python python /usr/bin/python3 10
cd /tmp
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
rm get-pip.py
&& apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*
5 changes: 3 additions & 2 deletions dockerhub/latest/operator-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM node:8.11 as build_js
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/static /var/www
Expand All @@ -11,4 +11,5 @@ 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
CMD if [ "$DEBUG" = "True" ]; then python dashboard.py ; else gunicorn -w 1 --worker-class eventlet -b 0.0.0.0:8080 dashboard:app ;fi
COPY --from=build_js /tmp/cello/src/celery.conf /etc/supervisor/conf.d/
CMD /etc/init.d/supervisor start && if [ "$DEBUG" = "True" ]; then python dashboard.py ; else gunicorn -w 1 --worker-class eventlet -b 0.0.0.0:8080 dashboard:app ;fi
19 changes: 9 additions & 10 deletions dockerhub/v0.9.0/baseimage/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM ubuntu:xenial
FROM busybox as downloader

RUN cd /tmp && wget -c https://github.com/hyperledger/cello/archive/v0.9.0.zip && \
unzip v0.9.0.zip && mv cello-0.9.0 cello

FROM python:3.6

LABEL maintainer="github.com/hyperledger/cello"

Expand All @@ -11,12 +16,6 @@ RUN cd /tmp/ && \
bash install.sh && \
rm -f /tmp/install.sh

# Clone code and put cello/src/* under /app
RUN cd /tmp && \
git clone https://github.com/hyperledger/cello.git && \
cd /tmp/cello && \
git checkout v0.8.0 && \
cp -r /tmp/cello/src/* /app && \
cd /app/ && \
pip install -r requirements.txt && \
rm -rf /tmp/cello
COPY --from=downloader /tmp/cello/src /app
RUN cd /app/ && \
pip install -r requirements.txt
81 changes: 1 addition & 80 deletions dockerhub/v0.9.0/baseimage/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,5 @@ set -x
# 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

# ----------------------------------------------------------------
# Install mongo
# ----------------------------------------------------------------

groupadd -r mongodb && useradd -r -g mongodb mongodb

apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates jq numactl sudo\
&& rm -rf /var/lib/apt/lists/*

# grab gosu for easy step-down from root
export GOSU_VERSION=1.10

set -x \
&& apt-get update && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/* \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true

mkdir /docker-entrypoint-initdb.d

# Add GPG Keys & update apt sources

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

echo "deb [ arch=amd64,arm64,ppc64el,s390x ] http://repo.mongodb.com/apt/ubuntu xenial/mongodb-enterprise/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-enterprise.list

apt-get update

export MONGO_PACKAGE=mongodb-enterprise
# export MONGO_REPO=repo.mongodb.com
# export MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO}

export MONGO_MAJOR=3.4
export MONGO_VERSION=3.4.10

apt-get install -y \
${MONGO_PACKAGE}=$MONGO_VERSION \
${MONGO_PACKAGE}-server=$MONGO_VERSION \
${MONGO_PACKAGE}-shell=$MONGO_VERSION \
${MONGO_PACKAGE}-mongos=$MONGO_VERSION \
${MONGO_PACKAGE}-tools=$MONGO_VERSION

mkdir -p /data/db /data/configdb \
&& chown -R mongodb:mongodb /data/db /data/configdb

# ----------------------------------------------------------------
# Install NodeJS
# ----------------------------------------------------------------
NODE_VER=8.9.0

ARCH=`uname -m | sed 's|i686|x86|' | sed 's|x86_64|x64|'`
NODE_PKG=node-v$NODE_VER-linux-$ARCH.tar.gz
SRC_PATH=/tmp/$NODE_PKG

# First remove any prior packages downloaded in case of failure
cd /tmp
rm -f node*.tar.gz
wget --quiet https://nodejs.org/dist/v$NODE_VER/$NODE_PKG
cd /usr/local && sudo tar --strip-components 1 -xzf $SRC_PATH
rm -f /tmp/node*.tar.gz

# ----------------------------------------------------------------
# Install python3 and pip
# ----------------------------------------------------------------
if [[ $ARCH = 'ppc64le' ]];then
apt-get install build-essential libssl-dev libffi-dev python3-dev libxslt-dev python3 -y
else
apt-get install python3 git -y
fi

update-alternatives --install /usr/bin/python python /usr/bin/python3 10
cd /tmp
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
rm get-pip.py
&& apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*
2 changes: 1 addition & 1 deletion dockerhub/v0.9.0/engine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM hyperledger/cello-baseimage:x86_64-0.8.0
FROM hyperledger/cello-baseimage:x86_64-0.9.0

# use this in development
CMD ["python", "restserver.py"]
Expand Down
15 changes: 9 additions & 6 deletions dockerhub/v0.9.0/operator-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM hyperledger/cello-baseimage:x86_64-0.8.0
FROM node:8.9 as build_js
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone -b 'v0.9.0' --single-branch --depth 1 https://github.com/hyperledger/cello.git
RUN cp -r /tmp/cello/src/static /var/www
RUN cd /var/www/dashboard && npm install && npm run build

# use this in development
CMD ["python", "dashboard.py"]

# use this in product
#CMD ["gunicorn", "-w", "128", "-b", "0.0.0.0:8080", "dashboard:app"]
FROM hyperledger/cello-baseimage:x86_64-0.9.0

COPY --from=build_js /var/www/dist /app/static/dist
COPY --from=build_js /tmp/cello/src/celery.conf /etc/supervisor/conf.d/
CMD /etc/init.d/supervisor start && if [ "$DEBUG" = "True" ]; then python dashboard.py ; else gunicorn -w 1 --worker-class eventlet -b 0.0.0.0:8080 dashboard:app ;fi
76 changes: 32 additions & 44 deletions dockerhub/v0.9.0/user-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,39 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM node:9.2 as build_login
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cd /tmp/cello && git checkout v0.8.0
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app && npm install --loglevel http && npm run build

FROM node:9.2 as build_home
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cd /tmp/cello && git checkout v0.8.0
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app/home && npm install --loglevel http && npm run build

FROM node:9.2 as build_dashboard
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cd /tmp/cello && git checkout v0.8.0
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app/dashboard && npm install --loglevel http && npm run build
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/v0.9.0.zip && unzip v0.9.0.zip && mv cello-0.9.0 cello

FROM node:9.2
FROM node:8.9
MAINTAINER haitao yue "hightall@me.com"
RUN npm install -g requirejs
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cd /tmp/cello && git checkout v0.8.0
COPY package.json /
COPY --from=builder /tmp/cello/user-dashboard/src/package.json /
COPY --from=builder /tmp/cello/user-dashboard/src/yarn.lock /
COPY --from=builder /tmp/cello/user-dashboard/src/packages /packages
COPY --from=builder /tmp/cello/user-dashboard/src /var/www
COPY --from=builder /tmp/cello/user-dashboard/fabric/fabric-1.0 /etc/hyperledger/fabric-1.0
COPY --from=builder /tmp/cello/user-dashboard/fabric/fabric-1.2 /etc/hyperledger/fabric-1.2
COPY --from=builder /tmp/cello/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 mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
WORKDIR /usr/app/src
ENV FABRIC_VERSION 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}/hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && tar -zxvf hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && mv bin/configtxgen /usr/local/bin/configtxgen
RUN mkdir -p /etc/hyperledger
RUN cp -r /tmp/cello/user-dashboard/fabric/fabric /etc/hyperledger/fabric
COPY --from=build_login /usr/app/src/src/public/js/dist /usr/app/src/src/public/js/dist
COPY --from=build_home /usr/app/src/src/public/js/dist /usr/app/src/src/public/js/dist
COPY --from=build_dashboard /usr/app/src/src/public/js/dist /usr/app/src/src/public/js/dist
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
EXPOSE 8080
CMD ["npm", "start"]
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
2 changes: 1 addition & 1 deletion dockerhub/v0.9.0/watchdog/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM hyperledger/cello-baseimage:x86_64-0.8.0
FROM hyperledger/cello-baseimage:x86_64-0.9.0

# use this in development
CMD ["python", "watchdog.py"]
Loading

0 comments on commit fefe906

Please sign in to comment.