From 5cf2350bffc9c51e49a93f02c074e10b362da7dc Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 8 Jul 2024 14:01:50 +0700 Subject: [PATCH 1/4] custom wget wasmvm --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index 3d08934c..d806f1dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,21 @@ FROM golang:1.22.4-alpine3.19 as go-builder WORKDIR /app +RUN apk add --no-cache ca-certificates build-base git + COPY go.mod go.sum* ./ +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ + -O /lib/libwasmvm_muslc.a && \ + # verify checksum + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ + sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.x86_64.so \ + -O /lib/libwasmvm.x86_64.so && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.aarch64.so \ + -O /lib/libwasmvm.aarch64.so + RUN go mod download COPY . . From c9237069e02b3ece62aa3d142687b75d0cab4d60 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 8 Jul 2024 14:08:54 +0700 Subject: [PATCH 2/4] change base image --- Dockerfile | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index d806f1dc..b7b1c751 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,34 @@ -FROM golang:1.22.4-alpine3.19 as go-builder - +# Use Ubuntu as the base image +FROM ubuntu:latest as go-builder + +# Install necessary dependencies +RUN apt-get update && apt-get install -y \ + wget make git \ + && rm -rf /var/lib/apt/lists/* + +# Download and install Go 1.21 +RUN wget https://golang.org/dl/go1.21.4.linux-amd64.tar.gz && \ + tar -xvf go1.21.4.linux-amd64.tar.gz && \ + mv go /usr/local && \ + rm go1.21.4.linux-amd64.tar.gz + +# Set Go environment variables +ENV GOROOT=/usr/local/go +ENV GOPATH=$HOME/go +ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH + +RUN apt-get update -y +RUN apt-get install build-essential -y +# Set the working directory WORKDIR /app -RUN apk add --no-cache ca-certificates build-base git - -COPY go.mod go.sum* ./ +# Download go dependencies +COPY go.mod go.sum ./ +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/root/go/pkg/mod \ + go mod download +# Cosmwasm - Download correct libwasmvm version RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ -O /lib/libwasmvm_muslc.a && \ @@ -17,22 +40,19 @@ RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.aarch64.so \ -O /lib/libwasmvm.aarch64.so -RUN go mod download - +# Copy the remaining files COPY . . -ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 - -RUN apk add --no-cache $PACKAGES - RUN make build BECH32_PREFIX=ethm -FROM alpine:3.16.1 +FROM ubuntu:latest -RUN apk add curl jq bash vim +RUN apt-get update -y -COPY --from=go-builder /app/build/rollapp-evm /usr/local/bin/rollappd +COPY --from=go-builder /app/build/rollapp-wasm /usr/local/bin/rollappd +COPY --from=go-builder /lib/libwasmvm.x86_64.so /lib/libwasmvm.x86_64.so +COPY --from=go-builder /lib/libwasmvm.aarch64.so /lib/libwasmvm.aarch64.so WORKDIR /app -EXPOSE 26657 1317 +EXPOSE 26657 1317 \ No newline at end of file From 8dec9debf94e7036ae770ac2aa2bd58a6cd91a14 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 8 Jul 2024 14:15:11 +0700 Subject: [PATCH 3/4] minor --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7b1c751..32e1eaa2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,10 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Download and install Go 1.21 -RUN wget https://golang.org/dl/go1.21.4.linux-amd64.tar.gz && \ - tar -xvf go1.21.4.linux-amd64.tar.gz && \ +RUN wget https://golang.org/dl/go1.22.4.linux-amd64.tar.gz && \ + tar -xvf go1.22.4.linux-amd64.tar.gz && \ mv go /usr/local && \ - rm go1.21.4.linux-amd64.tar.gz + rm go1.22.4.linux-amd64.tar.gz # Set Go environment variables ENV GOROOT=/usr/local/go @@ -49,7 +49,7 @@ FROM ubuntu:latest RUN apt-get update -y -COPY --from=go-builder /app/build/rollapp-wasm /usr/local/bin/rollappd +COPY --from=go-builder /app/build/rollapp-evm /usr/local/bin/rollappd COPY --from=go-builder /lib/libwasmvm.x86_64.so /lib/libwasmvm.x86_64.so COPY --from=go-builder /lib/libwasmvm.aarch64.so /lib/libwasmvm.aarch64.so From 64a201cad55178d3cdec0e161b62603761f71c50 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 8 Jul 2024 16:16:20 +0700 Subject: [PATCH 4/4] not supported by arm64 --- .github/workflows/build_and_push_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_push_images.yml b/.github/workflows/build_and_push_images.yml index 1b75a907..6fad804f 100644 --- a/.github/workflows/build_and_push_images.yml +++ b/.github/workflows/build_and_push_images.yml @@ -49,7 +49,7 @@ jobs: file: Dockerfile context: . push: true - platforms: linux/amd64, linux/arm64 + platforms: linux/amd64 tags: | ghcr.io/dymensionxyz/rollapp-evm:latest ghcr.io/dymensionxyz/rollapp-evm:${{ env.DOCKER_IMAGE_TAG }} \ No newline at end of file