From 07d834ccd1de0edf0becefd3219eeece0659b65a Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Wed, 28 Feb 2024 10:13:39 +0700 Subject: [PATCH] updated Dockerfile --- Dockerfile.cosmwasm | 25 ++++++++++--------------- Dockerfile.default | 2 +- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Dockerfile.cosmwasm b/Dockerfile.cosmwasm index b5364362c..1b93c6255 100644 --- a/Dockerfile.cosmwasm +++ b/Dockerfile.cosmwasm @@ -17,17 +17,14 @@ # To exit the bash, just execute # > exit FROM golang:1.20-alpine as builder -ARG arch=x86_64 +RUN apk update && apk add --no-cache make git +WORKDIR /go/src/github.com/forbole/bdjuno +COPY . ./ # Set up dependencies ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 ca-certificates build-base RUN set -eux; apk add --no-cache $PACKAGES; -# Set working directory for the build -WORKDIR /code - -# Add source files -COPY . /code/ # See https://github.com/CosmWasm/wasmvm/releases ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.3.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a @@ -36,19 +33,17 @@ RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep b1610f9c8ad8bdebf5b8f819f71d ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.3.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep b4aad4480f9b4c46635b4943beedbb72c929eab1d1b9467fe3b43e6dbf617e32 -# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` -RUN cp /lib/libwasmvm_muslc.${arch}.a /usr/local/lib/libwasmvm_muslc.a - -# force it to use static lib (from above) not standard libgo_cosmwasm.so file -RUN BUILD_TAGS=muslc GOOS=linux GOARCH=amd64 LINK_STATICALLY=true make build -RUN echo "Ensuring binary is statically linked ..." && (file /code/build/bdjuno | grep "statically linked") +## Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` +RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a +RUN go mod download +RUN LINK_STATICALLY=true BUILD_TAGS="muslc" make build FROM alpine:latest - # Set up dependencies RUN apk update && apk add --no-cache ca-certificates build-base +WORKDIR /bdjuno # Copy the binary -COPY --from=builder /code/build/bdjuno /usr/bin/bdjuno +COPY --from=builder /go/src/github.com/forbole/bdjuno/build/bdjuno /usr/bin/bdjuno -CMD ["bdjuno"] \ No newline at end of file +CMD [ "bdjuno" ] \ No newline at end of file diff --git a/Dockerfile.default b/Dockerfile.default index b67bc151e..638828f04 100644 --- a/Dockerfile.default +++ b/Dockerfile.default @@ -1,4 +1,4 @@ -FROM golang:1.21.5-alpine3.18 AS builder +FROM golang:1.20-alpine as builder RUN apk update && apk add --no-cache make git WORKDIR /go/src/github.com/forbole/bdjuno COPY . ./