Skip to content

Commit 1d6f879

Browse files
committed
Update workflow
1 parent 4d20399 commit 1d6f879

File tree

7 files changed

+97
-39
lines changed

7 files changed

+97
-39
lines changed

.github/workflows/build-&-publish-docker-image.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222
jobs:
2323
blobber:
2424
timeout-minutes: 30
25-
runs-on: [blobber-runner]
25+
runs-on: [hetzner-build]
2626
steps:
2727
- name: Cleanup before restarting conductor tests.
2828
run: |
@@ -95,19 +95,16 @@ jobs:
9595
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
9696
export DOCKER_IMAGE_BASE="$BLOBBER_BUILD_BASE_REGISTRY:$TAG"
9797
export DOCKER_IMAGE_SWAGGER="${BLOBBER_REGISTRY}:swagger_test"
98-
# export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"
99-
export DOCKER_BUILD="build --push"
98+
export DOCKER_BUILD="build"
10099
export DOCKER_IMAGE_BLOBBER="-t ${BLOBBER_REGISTRY}:${TAG}"
101-
export CONTEXT_NAME="$RUNNER_NAME" && (docker context inspect "$CONTEXT_NAME" >/dev/null 2>&1 || docker context create "$CONTEXT_NAME")
102-
docker buildx inspect "blobber-$RUNNER_NAME" || docker buildx create --name "blobber-$RUNNER_NAME" --driver-opt network=host --buildkitd-flags '--allow-insecure-entitlement security.insecure' "$CONTEXT_NAME"
103-
docker buildx use "blobber-$RUNNER_NAME"
104100
./docker.local/bin/build.blobber.sh
105101
docker tag ${BLOBBER_REGISTRY}:${TAG} ${BLOBBER_REGISTRY}:${TAG}-${SHORT_SHA}
102+
docker push ${BLOBBER_REGISTRY}:${TAG}
106103
docker push ${BLOBBER_REGISTRY}:${TAG}-${SHORT_SHA}
107104
108105
validator:
109106
timeout-minutes: 30
110-
runs-on: [blobber-runner]
107+
runs-on: [hetzner-build]
111108
steps:
112109
- name: Cleanup before restarting conductor tests.
113110
run: |
@@ -181,20 +178,17 @@ jobs:
181178
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
182179
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
183180
export DOCKER_IMAGE_BASE="$BLOBBER_BUILD_BASE_REGISTRY:$TAG"
184-
# export DOCKER_BUILD="buildx build --platform linux/amd64,linux/arm64 --push"
185-
export DOCKER_BUILD="build --push"
181+
export DOCKER_BUILD="build"
186182
export DOCKER_IMAGE_VALIDATOR="-t ${VALIDATOR_REGISTRY}:${TAG}"
187-
export CONTEXT_NAME="$RUNNER_NAME" && (docker context inspect "$CONTEXT_NAME" >/dev/null 2>&1 || docker context create "$CONTEXT_NAME")
188-
docker buildx inspect "validator-$RUNNER_NAME" || docker buildx create --name "validator-$RUNNER_NAME" --driver-opt network=host --buildkitd-flags '--allow-insecure-entitlement security.insecure' "$CONTEXT_NAME"
189-
docker buildx use "validator-$RUNNER_NAME"
190183
./docker.local/bin/build.validator.sh
191184
docker tag ${VALIDATOR_REGISTRY}:${TAG} ${VALIDATOR_REGISTRY}:${TAG}-${SHORT_SHA}
185+
docker push ${VALIDATOR_REGISTRY}:${TAG}
192186
docker push ${VALIDATOR_REGISTRY}:${TAG}-${SHORT_SHA}
193187
194188
system-tests:
195189
if: github.event_name != 'workflow_dispatch'
196190
needs: [blobber, validator]
197-
runs-on: [ tests-suite ]
191+
runs-on: [ hetzner-testsuite ]
198192
steps:
199193
- name: "Get current PR"
200194
uses: jwalton/gh-find-current-pr@v1

docker.local/base.Dockerfile

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,46 @@ FROM golang:1.22.0-alpine3.18 as blobber_base
22

33
LABEL zchain="blobber"
44

5-
RUN apk add --update --no-cache linux-headers build-base git cmake bash perl grep
5+
RUN apk add --update --no-cache linux-headers build-base git cmake bash perl grep
66

77
# Install Herumi's cryptography
88
WORKDIR /tmp
99

1010
RUN apk upgrade
1111
RUN apk del libstdc++ gmp-dev openssl-dev vips-dev
12-
RUN apk add --update --no-cache libstdc++ gmp-dev openssl-dev vips-dev
12+
RUN apk add --update --no-cache libstdc++ gmp-dev openssl-dev vips-dev
13+
14+
# Copy the herumi library tarballs (downloaded by build.base.sh)
15+
COPY docker.local/bin/mcl.tar.gz /tmp/
16+
COPY docker.local/bin/bls.tar.gz /tmp/
17+
18+
# Extract both archives first
19+
RUN tar -xzf mcl.tar.gz && \
20+
tar -xzf bls.tar.gz
21+
22+
# Build and install mcl
23+
RUN cd mcl-* && \
24+
mkdir -p build && \
25+
cd build && \
26+
cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
27+
make -j$(nproc) && \
28+
make install
29+
30+
# Build and install bls (copy mcl source into bls directory)
31+
RUN BLS_DIR=$(ls -d /tmp/bls-* | head -n 1) && \
32+
MCL_DIR=$(ls -d /tmp/mcl-* | head -n 1) && \
33+
cp -r "$MCL_DIR" "$BLS_DIR/mcl" && \
34+
cd "$BLS_DIR" && \
35+
mkdir -p build && \
36+
cd build && \
37+
cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
38+
make -j$(nproc) && \
39+
make install
40+
41+
# Clean up
42+
RUN cd /tmp && \
43+
rm -rf mcl-* bls-* mcl.tar.gz bls.tar.gz
44+
45+
# Verify libraries are installed
46+
RUN ls -la /usr/local/lib/libmcl* /usr/local/lib/libbls* && \
47+
echo "Herumi libraries successfully installed"

docker.local/bin/build.base.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,11 @@ echo "2> download herumi"
2727
[ ! -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
2828

2929
echo "3> docker build"
30-
DOCKER_BUILDKIT=1 docker $DOCKER_BUILD --progress=plain --build-arg GIT_COMMIT=$GIT_COMMIT -f docker.local/base.Dockerfile . -t $DOCKER_IMAGE_BASE --network host
30+
# Set progress flag only for buildx
31+
if [[ "$DOCKER_BUILD" == *"buildx"* ]]; then
32+
PROGRESS_FLAG="--progress=plain"
33+
else
34+
PROGRESS_FLAG=""
35+
fi
36+
37+
docker $DOCKER_BUILD $PROGRESS_FLAG --build-arg GIT_COMMIT=$GIT_COMMIT -f docker.local/base.Dockerfile . -t $DOCKER_IMAGE_BASE --network host

docker.local/bin/build.blobber.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ echo $GIT_COMMIT
77
echo "1> set DOCKER_IMAGE & DOCKER_BUILD"
88
if [ -z "$DOCKER_BUILD" ]; then
99
if [ "x86_64" != "$(uname -m)" ]; then
10-
#docker buildx use blobber_buildx || docker buildx create --name blobber_buildx --use
1110
DOCKER_BUILD="buildx build --platform linux/arm64"
1211
else
1312
DOCKER_BUILD="build"
@@ -28,9 +27,14 @@ echo " DOCKER_IMAGE_SWAGGER=$DOCKER_IMAGE_SWAGGER"
2827
echo " DOCKER_IMAGE_BLOBBER=$DOCKER_IMAGE_BLOBBER"
2928

3029
echo ""
30+
echo "2> docker build blobber"
3131

32-
# echo "generating swagger"
33-
# docker.local/bin/test.swagger.sh
32+
# Set flags based on build type
33+
if [[ "$DOCKER_BUILD" == *"buildx"* ]]; then
34+
BUILD_FLAGS="--progress=plain"
35+
export DOCKER_BUILDKIT=1
36+
else
37+
BUILD_FLAGS=""
38+
fi
3439

35-
echo "2> docker build blobber"
36-
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 --network host
40+
docker $DOCKER_BUILD $BUILD_FLAGS --build-arg GIT_COMMIT=$GIT_COMMIT --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -f docker.local/blobber.Dockerfile . $DOCKER_IMAGE_BLOBBER --network host

docker.local/bin/build.validator.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ echo $GIT_COMMIT
77
echo "1> set DOCKER_IMAGE & DOCKER_BUILD"
88
if [ -z "$DOCKER_BUILD" ]; then
99
if [ "x86_64" != "$(uname -m)" ]; then
10-
#docker buildx use blobber_buildx || docker buildx create --name blobber_buildx --use
1110
DOCKER_BUILD="buildx build --platform linux/arm64"
1211
else
1312
DOCKER_BUILD="build"
1413
fi
1514
fi
1615

17-
if [ -z "$DOCKER_IMAGE_BASE" ]; then
16+
if [ -z "$DOCKER_IMAGE_BASE" ]; then
1817
DOCKER_IMAGE_BASE="blobber_base"
1918
fi
2019

21-
if [ -z "$DOCKER_IMAGE_VALIDATOR" ]; then
20+
if [ -z "$DOCKER_IMAGE_VALIDATOR" ]; then
2221
DOCKER_IMAGE_VALIDATOR="-t validator"
2322
fi
2423

@@ -28,4 +27,13 @@ echo " DOCKER_IMAGE_VALIDATOR=$DOCKER_IMAGE_VALIDATOR"
2827

2928
echo ""
3029
echo "2> docker build validator"
31-
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
30+
31+
# Set flags based on build type
32+
if [[ "$DOCKER_BUILD" == *"buildx"* ]]; then
33+
BUILD_FLAGS="--progress=plain"
34+
export DOCKER_BUILDKIT=1
35+
else
36+
BUILD_FLAGS=""
37+
fi
38+
39+
docker $DOCKER_BUILD $BUILD_FLAGS --build-arg GIT_COMMIT=$GIT_COMMIT --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -f docker.local/validator.Dockerfile . $DOCKER_IMAGE_VALIDATOR

docker.local/blobber.Dockerfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# syntax=docker/dockerfile:1
2+
3+
# Declare ARG at the top, before any FROM
24
ARG DOCKER_IMAGE_BASE
3-
FROM $DOCKER_IMAGE_BASE as blobber_build
5+
6+
# Create a named stage from the base image
7+
FROM $DOCKER_IMAGE_BASE as base_image
8+
9+
FROM $DOCKER_IMAGE_BASE as blobber_build
410
LABEL zchain="blobber"
511

612
ENV SRC_DIR=/0chain
@@ -25,11 +31,12 @@ FROM alpine:3.18
2531

2632
RUN apk add --update --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main libstdc++ gmp openssl vips
2733

28-
COPY --from=blobber_build /usr/local/lib/libmcl*.so \
29-
/usr/local/lib/libbls*.so \
30-
/usr/local/lib/
34+
# Copy from the named base_image stage
35+
COPY --from=base_image /usr/local/lib/libmcl*.so \
36+
/usr/local/lib/libbls*.so \
37+
/usr/local/lib/
3138

3239
ENV APP_DIR=/blobber
3340
WORKDIR $APP_DIR
3441
COPY --from=blobber_build /0chain/code/go/0chain.net/blobber/blobber $APP_DIR/bin/blobber
35-
# COPY ./code/go/0chain.net/swagger.yaml /docs/swagger.yaml
42+
# COPY ./code/go/0chain.net/swagger.yaml /docs/swagger.yaml

docker.local/validator.Dockerfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# syntax=docker/dockerfile:1
2+
3+
# Declare ARG at the top, before any FROM
24
ARG DOCKER_IMAGE_BASE
3-
FROM $DOCKER_IMAGE_BASE as validator_build
45

5-
LABEL zchain="validator"
6+
# Create a named stage from the base image
7+
FROM $DOCKER_IMAGE_BASE as base_image
68

9+
FROM $DOCKER_IMAGE_BASE as validator_build
10+
LABEL zchain="validator"
711

812
ENV SRC_DIR=/0chain
913
ENV GO111MODULE=on
10-
#ENV GOPROXY=https://goproxy.cn,direct
11-
1214

1315
# Download the dependencies:
1416
# Will be cached if we don't change mod/sum files
1517
COPY . $SRC_DIR
16-
# COPY ./gosdk /gosdk
1718

18-
RUN cd $SRC_DIR/ && go mod download
19+
RUN cd $SRC_DIR/ && go mod download
1920

2021
WORKDIR $SRC_DIR/code/go/0chain.net/validator
2122
ARG GIT_COMMIT
@@ -27,9 +28,11 @@ FROM alpine:3.18
2728

2829
RUN apk add --update --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main libstdc++ gmp openssl vips
2930

30-
COPY --from=validator_build /usr/local/lib/libmcl*.so \
31-
/usr/local/lib/libbls*.so \
32-
/usr/local/lib/
31+
# Copy from the named base_image stage
32+
COPY --from=base_image /usr/local/lib/libmcl*.so \
33+
/usr/local/lib/libbls*.so \
34+
/usr/local/lib/
35+
3336
ENV APP_DIR=/validator
3437
WORKDIR $APP_DIR
3538
COPY --from=validator_build /0chain/code/go/0chain.net/validator/validator $APP_DIR/bin/validator

0 commit comments

Comments
 (0)