Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
76b8b77
fix(devops): build multi platform images
cnlangzi Mar 3, 2022
9c30400
fix(devops): build multi platform images
cnlangzi Mar 3, 2022
3633533
fix(devops): build multi platform images
cnlangzi Mar 3, 2022
92ed1eb
fix(devops): build multi platform images
cnlangzi Mar 3, 2022
92ac2d5
fix(devops): improved base.Dockerfile
cnlangzi Mar 3, 2022
b39b351
fix(devops): remove master.tar.gz
cnlangzi Mar 3, 2022
a12d244
fix(devops): remove master.tar.gz
cnlangzi Mar 3, 2022
fd14bf6
fix(devops): download herumi on shell instead of docker
cnlangzi Mar 3, 2022
2db5195
fix(devops): fixed docker buildx layer
cnlangzi Mar 3, 2022
7d54e69
fix(devops): fixed docker buildx layer
cnlangzi Mar 3, 2022
d82d9c1
fix(devops): fixed docker buildx layer
cnlangzi Mar 3, 2022
eff4289
fix(devops): fixed docker buildx layer
cnlangzi Mar 3, 2022
6a6cc9f
fix(devops): fixed docker buildx builder
cnlangzi Mar 3, 2022
1c90bdd
fix(devops): test cache options for buildx
cnlangzi Mar 4, 2022
6c12677
fix(devops): test --driver for buildx
cnlangzi Mar 4, 2022
658f786
fix(devops): test --driver for buildx
cnlangzi Mar 4, 2022
7200505
fix(devops): test --driver for buildx
cnlangzi Mar 4, 2022
469eb2a
fix(devops): fixed build stage name issue
cnlangzi Mar 4, 2022
5ec6572
fix(devops): build image for darwin/amd64
cnlangzi Mar 4, 2022
c93a7ca
fix(devops): removed darwin/amd64
cnlangzi Mar 4, 2022
bf3363a
fix(devops): format github action
cnlangzi Mar 4, 2022
5d64947
fix(devops): fixed DOCKER_IMAGE_VALIDATOR
cnlangzi Mar 4, 2022
ea5d144
fix(devops): fixed bls/mcl tags
cnlangzi Mar 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 26 additions & 38 deletions .github/workflows/build-&-publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,36 @@ jobs:

echo "BRANCH=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo ${GITHUB_REF#refs/*/} || echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV
echo "SHA=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo $GITHUB_SHA || echo '${{ github.event.pull_request.head.sha }}')" >> $GITHUB_ENV

- name: Setup go 1.17
uses: actions/setup-go@v2
with:
go-version: '1.17' # The Go version to download (if necessary) and use.

# - uses: actions/cache@v2
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-


- name: Clone blobber
uses: actions/checkout@v1

- name: Build blobber_base
run: ./docker.local/bin/build.base.sh

- name: Build blobber
run: ./docker.local/bin/build.blobber.sh

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Push blobber
- name: Build base
run: |
docker tag blobber:latest ${BLOBBER_REGISTRY}:$TAG
docker push ${BLOBBER_REGISTRY}:$TAG || { sleep 10 && docker push ${BLOBBER_REGISTRY}:$TAG; }
export DOCKER_IMAGE_BASE="${BLOBBER_REGISTRY}:base"
export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"
./docker.local/bin/build.base.sh

- name: Build blobber
run: |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
docker tag blobber:latest ${BLOBBER_REGISTRY}:$TAG-$SHORT_SHA
docker push ${BLOBBER_REGISTRY}:$TAG-$SHORT_SHA || { sleep 10 && docker push ${BLOBBER_REGISTRY}:$TAG-$SHORT_SHA; }

export DOCKER_IMAGE_BASE="${BLOBBER_REGISTRY}:base"
export DOCKER_IMAGE_BLOBBER="-t ${BLOBBER_REGISTRY}:${TAG} -t ${BLOBBER_REGISTRY}:${TAG}-${SHORT_SHA}"
export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"

./docker.local/bin/build.blobber.sh

validator:
runs-on: [self-hosted, build]
Expand All @@ -89,36 +82,31 @@ jobs:
with:
go-version: '1.17' # The Go version to download (if necessary) and use.

# - uses: actions/cache@v2
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-

- name: Clone blobber
uses: actions/checkout@v1

- name: Build blobber_base
run: ./docker.local/bin/build.base.sh

- name: Build validator
run: ./docker.local/bin/build.validator.sh

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Push validator
- name: Build base
run: |
docker tag validator:latest ${VALIDATOR_REGISTRY}:$TAG
docker push ${VALIDATOR_REGISTRY}:$TAG || { sleep 10 && docker push ${VALIDATOR_REGISTRY}:$TAG; }
export DOCKER_IMAGE_BASE="${VALIDATOR_REGISTRY}:base"
export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"
./docker.local/bin/build.base.sh

- name: Build validator
run: |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
docker tag validator:latest ${VALIDATOR_REGISTRY}:$TAG-$SHORT_SHA
docker push ${VALIDATOR_REGISTRY}:$TAG-$SHORT_SHA || { sleep 10 && docker push ${VALIDATOR_REGISTRY}:$TAG-$SHORT_SHA; }

export DOCKER_IMAGE_BASE="${VALIDATOR_REGISTRY}:base"
export DOCKER_IMAGE_VALIDATOR="-t ${VALIDATOR_REGISTRY}:${TAG} -t ${VALIDATOR_REGISTRY}:${TAG}-${SHORT_SHA}"
export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"

./docker.local/bin/build.validator.sh


system-tests:
if: github.event_name != 'workflow_dispatch'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ __debug_bin
dev.local/data
out/
**/tmp/
*.tar.gz
33 changes: 19 additions & 14 deletions docker.local/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM golang:1.17.1-alpine3.14 as blobber_base

LABEL zchain="blobber"

# https://mirrors.alpinelinux.org/
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN echo "https://mirrors.aliyun.com/alpine/v3.14/main" >> /etc/apk/repositories
Expand All @@ -16,21 +17,25 @@ RUN echo "https://uk.alpinelinux.org/alpine/v3.14/community" >> /etc/apk/reposit
RUN echo "https://dl-4.alpinelinux.org/alpine/v3.14/main" >> /etc/apk/repositories
RUN echo "https://dl-4.alpinelinux.org/alpine/v3.14/community" >> /etc/apk/repositories

RUN echo "https://mirror.yandex.ru/alpine/v3.14/main" >> /etc/apk/repositories
RUN echo "https://mirror.yandex.ru/alpine/v3.14/community" >> /etc/apk/repositories


RUN apk add --update --no-cache build-base linux-headers git cmake bash perl grep
RUN apk add --update --no-cache build-base linux-headers git cmake bash perl grep gmp gmp-dev openssl-dev

# Install Herumi's cryptography
RUN apk add gmp gmp-dev openssl-dev && \
cd /tmp && \
wget -O - https://github.com/herumi/mcl/archive/master.tar.gz | tar xz && \
wget -O - https://github.com/herumi/bls/archive/master.tar.gz | tar xz && \
mv mcl* mcl && \
mv bls* bls && \
make -C mcl -j $(nproc) lib/libmclbn256.so install && \
cp mcl/lib/libmclbn256.so /usr/local/lib && \
make MCL_DIR=$(pwd)/mcl -C bls -j $(nproc) install && \
rm -R /tmp/mcl && \
rm -R /tmp/bls
WORKDIR /tmp

COPY ./docker.local/bin/mcl.tar.gz ./
COPY ./docker.local/bin/bls.tar.gz ./

RUN tar zxvf mcl.tar.gz && rm mcl.tar.gz && mv mcl* mcl

RUN tar zxvf bls.tar.gz && rm bls.tar.gz && mv bls* bls

RUN make -C mcl -j $(nproc) lib/libmclbn256.so install
RUN cp mcl/lib/libmclbn256.so /usr/local/lib

RUN make MCL_DIR=$(pwd)/mcl -C bls -j $(nproc) install

RUN rm -R /tmp/mcl && rm -R /tmp/bls

#ENV GOPROXY=https://goproxy.cn
25 changes: 24 additions & 1 deletion docker.local/bin/build.base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ set -e

GIT_COMMIT=$(git rev-list -1 HEAD)
echo $GIT_COMMIT
echo "1> set DOCKER_IMAGE & DOCKER_BUILD"
if [ -z "$DOCKER_BUILD" ]; then
if [ "x86_64" != "$(uname -m)" ]; then
#docker buildx use blobber_buildx || docker buildx create --name blobber_buildx --use
DOCKER_BUILD="buildx build --platform linux/arm64"
else
DOCKER_BUILD="build"
fi
fi

if [ -z "$DOCKER_IMAGE_BASE" ]; then
DOCKER_IMAGE_BASE="blobber_base"
fi
echo " DOCKER_BUILD=$DOCKER_BUILD"
echo " DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE"

docker build --build-arg GIT_COMMIT=$GIT_COMMIT -f docker.local/base.Dockerfile . -t blobber_base
echo ""
echo "2> download herumi"

[ ! -f ./docker.local/bin/mcl.tar.gz ] && wget -O ./docker.local/bin/mcl.tar.gz https://github.com/herumi/mcl/archive/refs/tags/v1.57.tar.gz

[ ! -f ./docker.local/bin/bls.tar.gz ] && wget -O ./docker.local/bin/bls.tar.gz https://github.com/herumi/bls/archive/refs/tags/v1.22.tar.gz

echo ""
echo "3> docker build"
DOCKER_BUILDKIT=1 docker $DOCKER_BUILD --progress=plain --build-arg GIT_COMMIT=$GIT_COMMIT -f docker.local/base.Dockerfile . -t $DOCKER_IMAGE_BASE
35 changes: 21 additions & 14 deletions docker.local/bin/build.blobber.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@ set -e
GIT_COMMIT=$(git rev-list -1 HEAD)
echo $GIT_COMMIT

cmd="build"
echo "1> set DOCKER_IMAGE & DOCKER_BUILD"
if [ -z "$DOCKER_BUILD" ]; then
if [ "x86_64" != "$(uname -m)" ]; then
#docker buildx use blobber_buildx || docker buildx create --name blobber_buildx --use
DOCKER_BUILD="buildx build --platform linux/arm64"
else
DOCKER_BUILD="build"
fi
fi

for arg in "$@"
do
case $arg in
-m1|--m1|m1)
echo "The build will be performed for Apple M1 chip"
cmd="buildx build --platform linux/amd64"
shift
;;
esac
done
if [ -z "$DOCKER_IMAGE_BASE" ]; then
DOCKER_IMAGE_BASE="blobber_base"
fi

# [ -d ./gosdk ] && rm -rf gosdk
# cp -r ../gosdk ./
if [ -z "$DOCKER_IMAGE_BLOBBER" ]; then
DOCKER_IMAGE_BLOBBER="-t blobber"
fi

echo " DOCKER_BUILD=$DOCKER_BUILD"
echo " DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE"
echo " DOCKER_IMAGE_BLOBBER=$DOCKER_IMAGE_BLOBBER"

docker $cmd --build-arg GIT_COMMIT=$GIT_COMMIT -f docker.local/blobber.Dockerfile . -t blobber
echo ""

echo "2> docker build blobber"
DOCKER_BUILDKIT=1 docker $DOCKER_BUILD --progress=plain --build-arg GIT_COMMIT=$GIT_COMMIT --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -f docker.local/blobber.Dockerfile . $DOCKER_IMAGE_BLOBBER
35 changes: 21 additions & 14 deletions docker.local/bin/build.validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,28 @@ set -e
GIT_COMMIT=$(git rev-list -1 HEAD)
echo $GIT_COMMIT

cmd="build"
echo "1> set DOCKER_IMAGE & DOCKER_BUILD"
if [ -z "$DOCKER_BUILD" ]; then
if [ "x86_64" != "$(uname -m)" ]; then
#docker buildx use blobber_buildx || docker buildx create --name blobber_buildx --use
DOCKER_BUILD="buildx build --platform linux/arm64"
else
DOCKER_BUILD="build"
fi
fi

for arg in "$@"
do
case $arg in
-m1|--m1|m1)
echo "The build will be performed for Apple M1 chip"
cmd="buildx build --platform linux/amd64"
shift
;;
esac
done
if [ -z "$DOCKER_IMAGE_BASE" ]; then
DOCKER_IMAGE_BASE="blobber_base"
fi

# [ -d ./gosdk ] && rm -rf gosdk
# cp -r ../gosdk ./
if [ -z "$DOCKER_IMAGE_VALIDATOR" ]; then
DOCKER_IMAGE_VALIDATOR="-t validator"
fi

docker $cmd --build-arg GIT_COMMIT=$GIT_COMMIT -f docker.local/validator.Dockerfile . -t validator
echo " DOCKER_BUILD=$DOCKER_BUILD"
echo " DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE"
echo " DOCKER_IMAGE_VALIDATOR=$DOCKER_IMAGE_VALIDATOR"

echo ""
echo "2> docker build validator"
DOCKER_BUILDKIT=1 docker $DOCKER_BUILD --progress=plain --build-arg GIT_COMMIT=$GIT_COMMIT --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -f docker.local/validator.Dockerfile . $DOCKER_IMAGE_VALIDATOR
4 changes: 3 additions & 1 deletion docker.local/blobber.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM blobber_base as blobber_build
# syntax=docker/dockerfile:1
ARG DOCKER_IMAGE_BASE
FROM $DOCKER_IMAGE_BASE as blobber_build
LABEL zchain="blobber"

ENV SRC_DIR=/0chain
Expand Down
10 changes: 6 additions & 4 deletions docker.local/validator.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM blobber_base as validator_build
# syntax=docker/dockerfile:1
ARG DOCKER_IMAGE_BASE
FROM $DOCKER_IMAGE_BASE as validator_build

LABEL zchain="validator"


ENV SRC_DIR=/blobber
ENV SRC_DIR=/0chain
ENV GO111MODULE=on
#ENV GOPROXY=https://goproxy.cn,direct

Expand All @@ -25,6 +27,6 @@ RUN apk add gmp gmp-dev openssl-dev
COPY --from=validator_build /usr/local/lib/libmcl*.so \
/usr/local/lib/libbls*.so \
/usr/local/lib/
ENV APP_DIR=/blobber
ENV APP_DIR=/validator
WORKDIR $APP_DIR
COPY --from=validator_build $APP_DIR/code/go/0chain.net/validator/validator $APP_DIR/bin/validator
COPY --from=validator_build /0chain/code/go/0chain.net/validator/validator $APP_DIR/bin/validator