Remove reproducible builder image (#7484)

The image has been moved to gh/tendemrint/images.
This commit is contained in:
Alessio Treglia 2020-10-08 15:00:34 +01:00 committed by GitHub
parent c39dd9eb38
commit 1671c87b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 123 deletions

View File

@ -110,10 +110,10 @@ $(BUILDDIR)/:
mkdir -p $(BUILDDIR)/
build-simd-all: go.sum
$(if $(shell docker inspect -f '{{ .Id }}' cosmossdk/rbuilder 2>/dev/null),$(info found image cosmossdk/rbuilder),docker pull cosmossdk/rbuilder:latest)
docker pull cosmossdk/rbuilder:latest
docker rm latest-build || true
docker run --volume=$(CURDIR):/sources:ro \
--env TARGET_OS='darwin linux windows' \
--env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm64 windows/amd64' \
--env APP=simd \
--env VERSION=$(VERSION) \
--env COMMIT=$(COMMIT) \
@ -122,10 +122,10 @@ build-simd-all: go.sum
docker cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
build-simd-linux: go.sum $(BUILDDIR)/
$(if $(shell docker inspect -f '{{ .Id }}' cosmossdk/rbuilder 2>/dev/null),$(info found image cosmossdk/rbuilder),docker pull cosmossdk/rbuilder:latest)
docker pull cosmossdk/rbuilder:latest
docker rm latest-build || true
docker run --volume=$(CURDIR):/sources:ro \
--env TARGET_OS='linux' \
--env TARGET_PLATFORMS='linux/amd64' \
--env APP=simd \
--env VERSION=$(VERSION) \
--env COMMIT=$(COMMIT) \

View File

@ -18,22 +18,27 @@ set -ue
# - OUTDIR
# Build for each os-architecture pair
for os in ${TARGET_OS} ; do
archs="`f_build_archs ${os}`"
exe_file_extension="`f_binary_file_ext ${os}`"
for arch in ${archs} ; do
make clean
GOOS="${os}" GOARCH="${arch}" GOROOT_FINAL="$(go env GOROOT)" \
make build \
LDFLAGS=-buildid=${VERSION} \
VERSION=${VERSION} \
COMMIT=${COMMIT} \
LEDGER_ENABLED=${LEDGER_ENABLED}
mv ./build/${APP}${exe_file_extension} ${OUTDIR}/${APP}-${VERSION}-${os}-${arch}${exe_file_extension}
done
unset exe_file_extension
for platform in ${TARGET_PLATFORMS} ; do
# This function sets GOOS, GOARCH, and OS_FILE_EXT environment variables
# according to the build target platform. OS_FILE_EXT is empty in all
# cases except when the target platform is 'windows'.
setup_build_env_for_platform "${platform}"
make clean
echo Building for $(go env GOOS)/$(go env GOARCH) >&2
GOROOT_FINAL="$(go env GOROOT)" \
make build \
LDFLAGS=-buildid=${VERSION} \
VERSION=${VERSION} \
COMMIT=${COMMIT} \
LEDGER_ENABLED=${LEDGER_ENABLED}
mv ./build/${APP}${OS_FILE_EXT} ${OUTDIR}/${APP}-${VERSION}-$(go env GOOS)-$(go env GOARCH)${OS_FILE_EXT}
# This function restore the build environment variables to their
# original state.
restore_build_env
done
# Generate and display build report
f_generate_build_report ${OUTDIR}
# Generate and display build report.
generate_build_report
cat ${OUTDIR}/build_report

View File

@ -3,7 +3,4 @@ all: simd-env
simd-env:
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag cosmossdk/simd-env simd-env
rbuilder:
docker build --tag cosmossdk/rbuilder rbuilder
.PHONY: all simd-env rbuilder
.PHONY: all simd-env

View File

@ -1,19 +0,0 @@
FROM golang:1.15.0-buster
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get --no-install-recommends -y install \
pciutils build-essential git wget \
lsb-release dpkg-dev curl bsdmainutils fakeroot
RUN mkdir -p /usr/local/share/cosmos-sdk/
COPY buildlib.sh /usr/local/share/cosmos-sdk/
RUN useradd -ms /bin/bash -U builder
ARG APP
ARG DEBUG
ENV APP ${APP:-cosmos-sdk}
ENV DEBUG ${DEBUG}
ENV VERSION unknown
ENV COMMIT unknown
ENV LEDGER_ENABLE true
USER builder:builder
WORKDIR /sources
VOLUME [ "/sources" ]
ENTRYPOINT [ "/sources/build.sh" ]

View File

@ -1,80 +0,0 @@
#/bin/bash
f_make_release_tarball() {
SOURCEDIST=${BASEDIR}/${APP}-${VERSION}.tar.gz
git archive --format tar.gz --prefix "${APP}-${VERSION}/" -o "${SOURCEDIST}" HEAD
l_tempdir="$(mktemp -d)"
pushd "${l_tempdir}" >/dev/null
tar xf "${SOURCEDIST}"
rm "${SOURCEDIST}"
find ${APP}-* | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > "${SOURCEDIST}"
popd >/dev/null
rm -rf "${l_tempdir}"
}
f_setup_pristine_src_dir() {
cd ${pristinesrcdir}
tar --strip-components=1 -xf "${SOURCEDIST}"
go mod download
}
f_build_archs() {
local l_os
l_os=$1
case "${l_os}" in
darwin | windows)
echo 'amd64'
;;
linux)
echo 'amd64 arm64'
;;
*)
echo "unknown OS -- ${l_os}" >&2
return 1
esac
}
f_binary_file_ext() {
[ $1 = windows ] && printf '%s' '.exe' || printf ''
}
f_generate_build_report() {
local l_tempfile
l_tempfile="$(mktemp)"
pushd "${OUTDIR}" >/dev/null
cat >>"${l_tempfile}" <<EOF
App: ${APP}
Version: ${VERSION}
Commit: ${COMMIT}
EOF
echo 'Files:' >> "${l_tempfile}"
md5sum * | sed 's/^/ /' >> "${l_tempfile}"
echo 'Checksums-Sha256:' >> "${l_tempfile}"
sha256sum * | sed 's/^/ /' >> "${l_tempfile}"
mv "${l_tempfile}" build_report
popd >/dev/null
}
[ "x${DEBUG}" = "x" ] || set -x
BASEDIR="$(mktemp -d)"
OUTDIR=$HOME/artifacts
rm -rfv ${OUTDIR}/
mkdir -p ${OUTDIR}/
pristinesrcdir=${BASEDIR}/buildsources
mkdir -p ${pristinesrcdir}
# Make release tarball
f_make_release_tarball
# Extract release tarball and cache dependencies
f_setup_pristine_src_dir
# Move the release tarball to the out directory
mv ${SOURCEDIST} ${OUTDIR}/