Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danbryan committed Apr 15, 2024
1 parent 2cf33db commit 78ecef8
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 2 deletions.
120 changes: 120 additions & 0 deletions babylond/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion kujirad/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion odind/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].*/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

Expand Down

0 comments on commit 78ecef8

Please sign in to comment.