From 78ecef818de527db639a6f80aefa1e8f5bafd952 Mon Sep 17 00:00:00 2001 From: danb Date: Sun, 14 Apr 2024 22:44:08 -0400 Subject: [PATCH] updates --- babylond/Dockerfile | 120 ++++++++++++++++++++++++++++++++++++++++++++ kujirad/Dockerfile | 2 +- odind/Dockerfile | 2 +- 3 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 babylond/Dockerfile diff --git a/babylond/Dockerfile b/babylond/Dockerfile new file mode 100644 index 0000000..ce68c44 --- /dev/null +++ b/babylond/Dockerfile @@ -0,0 +1,120 @@ +FROM golang:1.21-alpine3.17 AS build-env + +# Customize to your build env + +# TARGETPLATFORM should be one of linux/amd64 or linux/arm64. +ARG TARGETPLATFORM + +# Use muslc for static libs +ARG BUILD_TAGS=muslc +ARG VERSION +ARG LD_FLAGS=-linkmode=external \ +-extldflags '-Wl,-z,muldefs -static' + +# Install cli tools for building and final image +RUN apk add --update --no-cache make git bash gcc linux-headers eudev-dev ncurses-dev openssh curl jq +RUN apk add --no-cache musl-dev + +# Build +WORKDIR /go/src/github.com/babylonchain +RUN git clone https://github.com/babylonchain/babylon.git +WORKDIR /go/src/github.com/babylonchain/babylon +RUN git fetch +RUN git checkout ${VERSION} +WORKDIR /go/src/github.com/babylonchain/babylon + +# Install CosmWasm. +RUN set -eux; \ + WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $NF}'); \ + echo ${WASM_VERSION} ;\ + if [ ! -z "${WASM_VERSION}" ]; then \ + wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.$(uname -m).a; \ + fi; \ + go mod download; + +# Build Chain Binary +RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ] ; then \ + BUILD_TAGS=${BUILD_TAGS} make install ; \ + fi + +RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ] ; then \ + BUILD_TAGS=${BUILD_TAGS} make install ; \ + fi + +# Use busybox to create a user +FROM busybox:stable-musl AS busybox +RUN addgroup --gid 1137 -S defiant && adduser --uid 1137 -S defiant -G defiant + +# Use scratch for the final image +FROM scratch +WORKDIR /bin + +# Label should match your github repo +LABEL org.opencontainers.image.source="https://github.com/defiantchain/babylond:${VERSION}" + +# Installs all binaries built with go. +COPY --from=build-env /go/bin/babylond /bin + +# Other binaries we want to keep. +COPY --from=build-env /usr/bin/ldd /bin/ldd +COPY --from=build-env /usr/bin/curl /bin/curl +COPY --from=build-env /usr/bin/jq /bin/jq + +# Install Libraries +COPY --from=build-env /usr/lib/libgcc_s.so.1 /lib/ +COPY --from=build-env /lib/ld-musl*.so.1* /lib + +# jq Libraries +COPY --from=build-env /usr/lib/libonig.so.5 /lib + +# curl Libraries +COPY --from=build-env /usr/lib/libcurl.so.4 /lib +COPY --from=build-env /lib/libz.so.1 /lib +COPY --from=build-env /usr/lib/libnghttp2.so.14 /lib +COPY --from=build-env /lib/libssl.so* /lib +COPY --from=build-env /lib/libcrypto.so* /lib +COPY --from=build-env /usr/lib/libbrotlidec.so.1 /lib +COPY --from=build-env /usr/lib/libbrotlicommon.so.1 /lib + +# Install trusted CA certificates for curl +COPY --from=build-env /etc/ssl/cert.pem /etc/ssl/cert.pem +COPY --from=build-env /etc/ssl/cert.pem /etc/ssl/ca-certificates.crt +COPY --from=build-env /etc/ssl/cert.pem /etc/ssl/certs/ca-certificates.crt + +# Install cli tools from busybox +COPY --from=busybox /bin/ln /bin/ln +COPY --from=busybox /bin/ln /bin/sh + +# Link each binary you want to sh to save space. +RUN for binary in \ +dd \ +vi \ +chown \ +id \ +cp \ +ls \ +sh \ +cat \ +less \ +grep \ +sleep \ +env \ +tar \ +tee \ +du \ +sort \ +head \ +df \ +nc \ +netstat \ +; do ln sh $binary; done + + +# Copy user +COPY --from=busybox /etc/passwd /etc/passwd +COPY --from=busybox --chown=1137:1137 /home/defiant /home/defiant + +# Set home directory and user +WORKDIR /home/defiant +RUN chown -R defiant /home/defiant +USER defiant diff --git a/kujirad/Dockerfile b/kujirad/Dockerfile index 5213443..3fddbcf 100644 --- a/kujirad/Dockerfile +++ b/kujirad/Dockerfile @@ -6,7 +6,7 @@ ARG TARGETPLATFORM # Use muslc for static libs ARG BUILD_TAGS="muslc" ARG VERSION=v0.9.3-1 -ARG ORACLE_VERSION=v0.9.0 +ARG ORACLE_VERSION=v0.12.3 ARG LD_FLAGS=-linkmode=external \ -extldflags '-Wl,-z,muldefs -static' diff --git a/odind/Dockerfile b/odind/Dockerfile index 7e02360..c7f8d7f 100644 --- a/odind/Dockerfile +++ b/odind/Dockerfile @@ -50,7 +50,7 @@ COPY --from=build-env /usr/bin/ldd /bin/ldd COPY --from=build-env /usr/bin/curl /bin/curl COPY --from=build-env /usr/bin/jq /bin/jq COPY --from=build-env /go/pkg/mod/github.com/odin-protocol/go-owasm@v0.2.*/api/libgo_owasm.so /usr/lib/ -COPY --from=build-env /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.*.0/internal/api/libwasmvm.x86_64.so /usr/lib/ +# COPY --from=build-env /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.*.0/internal/api/libwasmvm.x86_64.so /usr/lib/ RUN apt-get update && apt-get install -y ca-certificates