mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-04 16:54:28 +00:00
Update bazel docker builds
- Adds oci_tarball build for local docker images. - Adds bazel-in-docker script & dockerfile. - Removes static image tags. - Updates docker repository.
This commit is contained in:
parent
38f208d70d
commit
cca294cba1
3
.gitignore
vendored
3
.gitignore
vendored
@ -44,3 +44,6 @@ tmp
|
|||||||
|
|
||||||
# spectest coverage reports
|
# spectest coverage reports
|
||||||
report.txt
|
report.txt
|
||||||
|
|
||||||
|
# bazel-in-docker
|
||||||
|
.bazel-in-docker*
|
||||||
|
47
Dockerfile.builder
Normal file
47
Dockerfile.builder
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# bazel-in-docker builder, for use with the build-in-docker.sh script and as a base image in pipelines
|
||||||
|
FROM ubuntu:22.04 as builder
|
||||||
|
|
||||||
|
# install build dependencies
|
||||||
|
RUN apt update && apt install -y cmake git libssl-dev libgmp-dev libtinfo5 unzip curl g++ python3 ca-certificates xz-utils
|
||||||
|
|
||||||
|
# install protoc at specific required version
|
||||||
|
RUN PROTOC_ZIP=protoc-3.14.0-linux-x86_64.zip && \
|
||||||
|
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$PROTOC_ZIP && \
|
||||||
|
unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \
|
||||||
|
unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \
|
||||||
|
rm -f $PROTOC_ZIP
|
||||||
|
|
||||||
|
# install bazelisk
|
||||||
|
RUN curl -o bazelisk -L https://github.com/bazelbuild/bazelisk/releases/download/v1.14.0/bazelisk-linux-amd64 && \
|
||||||
|
chmod +x bazelisk && \
|
||||||
|
mv bazelisk /usr/local/bin && \
|
||||||
|
ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel && \
|
||||||
|
bazelisk --version
|
||||||
|
|
||||||
|
# add the official docker certificates (for installing docker-cli)
|
||||||
|
RUN install -m 0755 -d /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
|
||||||
|
# add the official docker repository to apt sources
|
||||||
|
RUN echo \
|
||||||
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
|
||||||
|
| tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
|
||||||
|
# install docker-cli for use in pipeline builds
|
||||||
|
RUN apt update && apt install -y docker-ce-cli
|
||||||
|
|
||||||
|
# create app placeholder
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# prevent git warnings throughout build process
|
||||||
|
RUN git config --global --add safe.directory /app
|
||||||
|
|
||||||
|
# this command is only run in local builds when using the build-in-docker script
|
||||||
|
# perform the build then print output directory mappings
|
||||||
|
CMD bazel build --config=release //cmd/beacon-chain:oci_tarball && \
|
||||||
|
bazel build --config=release //cmd/validator:oci_tarball && \
|
||||||
|
bazel build --config=release //cmd/prysmctl:oci_tarball && \
|
||||||
|
ls -l | grep -o bazel-.* | sed 's/\/root\/.cache/.bazel-in-docker-cache/g' | awk '{print "ln -sf " $3 " " $1}' > .bazel-in-docker-outputs && \
|
||||||
|
chmod 666 .bazel-in-docker-outputs
|
11
README.md
11
README.md
@ -35,3 +35,14 @@ Want to get involved? Check out our [Contribution Guide](https://docs.prylabs.ne
|
|||||||
## Legal Disclaimer
|
## Legal Disclaimer
|
||||||
|
|
||||||
[Terms of Use](/TERMS_OF_SERVICE.md)
|
[Terms of Use](/TERMS_OF_SERVICE.md)
|
||||||
|
|
||||||
|
# Bazel-in-Docker Build
|
||||||
|
|
||||||
|
To get started quickly, a bazel-in-docker script is included that allows for producing local docker image builds without setting up bazel, protoc, and the various build dependencies.
|
||||||
|
|
||||||
|
This [Dockerfile](Dockerfile.builder) and [shell script](build-in-docker.sh) will produce consistent builds using Bazel-in-Docker while still taking advantage of bazel caching for fast repeat builds.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# run the bazel build in docker
|
||||||
|
./build-in-docker.sh
|
||||||
|
```
|
||||||
|
38
build-in-docker.sh
Executable file
38
build-in-docker.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# This is a convenience script for devs which runs bazel within
|
||||||
|
# docker to build and load local docker images.
|
||||||
|
# - Removes dependency requirements (other than docker)
|
||||||
|
# - Uses mounted directories for bazel caching (fast builds)
|
||||||
|
# - Does NOT push images to remote repository
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
# exit on failures
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# build the prysm-builder image
|
||||||
|
docker build --platform linux/amd64 -f Dockerfile.builder -t prysm-builder .
|
||||||
|
|
||||||
|
# run the build
|
||||||
|
docker run --platform linux/amd64 -it -v $(pwd):/app -v $(pwd)/.bazel-in-docker-cache:/root/.cache prysm-builder
|
||||||
|
|
||||||
|
# source the outputs file to build the correct symlink directories: bazel-*
|
||||||
|
source .bazel-in-docker-outputs
|
||||||
|
rm .bazel-in-docker-outputs
|
||||||
|
|
||||||
|
# load new images into docker
|
||||||
|
docker load -i bazel-bin/cmd/beacon-chain/oci_tarball/tarball.tar
|
||||||
|
docker load -i bazel-bin/cmd/validator/oci_tarball/tarball.tar
|
||||||
|
docker load -i bazel-bin/cmd/prysmctl/oci_tarball/tarball.tar
|
||||||
|
|
||||||
|
# finish up
|
||||||
|
echo ""
|
||||||
|
echo "Build Complete! Bazel outputs are available in the following directories:"
|
||||||
|
ls | grep bazel- | tr '\n' '\t'
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# print new docker images
|
||||||
|
echo ""
|
||||||
|
echo "Docker images loaded:"
|
||||||
|
docker image ls | grep --color=never -E "REPOSITORY|prysm-pulse.* local"
|
@ -73,10 +73,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":beacon-chain",
|
binary = ":beacon-chain",
|
||||||
entrypoint = ["/beacon-chain"],
|
entrypoint = ["/beacon-chain"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/beacon-chain",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/beacon-chain",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/cmd/beacon-chain/beacon-chain": "/beacon-chain",
|
"/app/cmd/beacon-chain/beacon-chain": "/beacon-chain",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -30,10 +30,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":prysmctl",
|
binary = ":prysmctl",
|
||||||
entrypoint = ["/prysmctl"],
|
entrypoint = ["/prysmctl"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/cmd/prysmctl",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/prysmctl",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/cmd/prysmctl/prysmctl": "/prysmctl",
|
"/app/cmd/prysmctl/prysmctl": "/prysmctl",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -60,10 +60,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":validator",
|
binary = ":validator",
|
||||||
entrypoint = ["/validator"],
|
entrypoint = ["/validator"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/validator",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/validator",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/cmd/validator/validator": "/validator",
|
"/app/cmd/validator/validator": "/validator",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
echo "Sorry, but prysm.bat cannot be used for PulseChain at this time."
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
SetLocal EnableDelayedExpansion & REM All variables are set local to this run & expanded at execution time rather than at parse time (tip: echo !output!)
|
SetLocal EnableDelayedExpansion & REM All variables are set local to this run & expanded at execution time rather than at parse time (tip: echo !output!)
|
||||||
|
|
||||||
set PRYLABS_SIGNING_KEY=0AE0051D647BA3C1A917AF4072E33E4DF1A5036E
|
set PRYLABS_SIGNING_KEY=0AE0051D647BA3C1A917AF4072E33E4DF1A5036E
|
||||||
|
3
prysm.sh
3
prysm.sh
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Sorry, but prysm.sh cannot be used for PulseChain at this time."
|
||||||
|
exit 1
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Use this script to download the latest Prysm release binary.
|
# Use this script to download the latest Prysm release binary.
|
||||||
|
@ -60,10 +60,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":bootnode",
|
binary = ":bootnode",
|
||||||
entrypoint = ["/bootnode"],
|
entrypoint = ["/bootnode"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/bootnode",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/bootnode",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/tools/bootnode/bootnode": "/bootnode",
|
"/app/tools/bootnode/bootnode": "/bootnode",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -28,10 +28,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":enr-calculator",
|
binary = ":enr-calculator",
|
||||||
entrypoint = ["/enr-calculator"],
|
entrypoint = ["/enr-calculator"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/enr-calculator",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/enr-calculator",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/tools/enr-calculator/enr-calculator": "/enr-calculator",
|
"/app/tools/enr-calculator/enr-calculator": "/enr-calculator",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -26,10 +26,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":eth1exporter",
|
binary = ":eth1exporter",
|
||||||
entrypoint = ["/eth1exporter"],
|
entrypoint = ["/eth1exporter"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/eth1monitor",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/eth1monitor",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/tools/eth1exporter/eth1exporter": "/eth1exporter",
|
"/app/tools/eth1exporter/eth1exporter": "/eth1exporter",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -30,10 +30,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":http-request-sink",
|
binary = ":http-request-sink",
|
||||||
entrypoint = ["/http-request-sink"],
|
entrypoint = ["/http-request-sink"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/http-request-sink",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/http-request-sink",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/tools/http-request-sink/http-request-sink": "/http-request-sink",
|
"/app/tools/http-request-sink/http-request-sink": "/http-request-sink",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -38,10 +38,9 @@ prysm_image_upload(
|
|||||||
name = "push_images",
|
name = "push_images",
|
||||||
binary = ":pcli",
|
binary = ":pcli",
|
||||||
entrypoint = ["/pcli"],
|
entrypoint = ["/pcli"],
|
||||||
repository = "gcr.io/prysmaticlabs/prysm/pcli",
|
repository = "registry.gitlab.com/pulsechaincom/prysm-pulse/pcli",
|
||||||
symlinks = {
|
symlinks = {
|
||||||
# Backwards compatibility for images that depended on the old filepath.
|
# Backwards compatibility for images that depended on the old filepath.
|
||||||
"/app/tools/pcli/pcli": "/pcli",
|
"/app/tools/pcli/pcli": "/pcli",
|
||||||
},
|
},
|
||||||
tags = ["manual"],
|
|
||||||
)
|
)
|
||||||
|
@ -7,13 +7,11 @@ def prysm_image_upload(
|
|||||||
binary,
|
binary,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
symlinks,
|
symlinks,
|
||||||
repository,
|
repository):
|
||||||
tags):
|
|
||||||
pkg_tar(
|
pkg_tar(
|
||||||
name = "binary_tar",
|
name = "binary_tar",
|
||||||
srcs = [binary],
|
srcs = [binary],
|
||||||
symlinks = symlinks,
|
symlinks = symlinks,
|
||||||
tags = tags,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
oci_image(
|
oci_image(
|
||||||
@ -45,9 +43,8 @@ def prysm_image_upload(
|
|||||||
":binary_tar",
|
":binary_tar",
|
||||||
],
|
],
|
||||||
labels = {
|
labels = {
|
||||||
"org.opencontainers.image.source": "https://github.com/prysmaticlabs/prysm",
|
"org.opencontainers.image.source": "https://gitlab.com/pulsechaincom/prysm-pulse",
|
||||||
},
|
},
|
||||||
tags = tags,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
multi_arch(
|
multi_arch(
|
||||||
@ -57,7 +54,6 @@ def prysm_image_upload(
|
|||||||
"@io_bazel_rules_go//go/toolchain:linux_amd64_cgo",
|
"@io_bazel_rules_go//go/toolchain:linux_amd64_cgo",
|
||||||
"@io_bazel_rules_go//go/toolchain:linux_arm64_cgo",
|
"@io_bazel_rules_go//go/toolchain:linux_arm64_cgo",
|
||||||
],
|
],
|
||||||
tags = tags,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
oci_image_index(
|
oci_image_index(
|
||||||
@ -65,18 +61,21 @@ def prysm_image_upload(
|
|||||||
images = [
|
images = [
|
||||||
":oci_multiarch",
|
":oci_multiarch",
|
||||||
],
|
],
|
||||||
tags = tags,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# oci_push rule is used to push the multi-platform image to the registry
|
||||||
|
# must pass a docker image --tag
|
||||||
oci_push(
|
oci_push(
|
||||||
name = name,
|
name = name,
|
||||||
image = ":oci_image_index",
|
image = ":oci_image_index",
|
||||||
repository = repository,
|
repository = repository,
|
||||||
tags = tags,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
oci_tarball(
|
# oci_tarball rule is used to create an image that can be loaded by the local docker runtime
|
||||||
name = "oci_image_tarball",
|
oci_tarball (
|
||||||
|
name = "oci_tarball",
|
||||||
image = ":oci_image",
|
image = ":oci_image",
|
||||||
repo_tags = [repository+":latest"],
|
repo_tags = [
|
||||||
|
repository + ":local"
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user