From 75c7adbd6cf6d3c368b9cf158c8c232f2ea63938 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Wed, 20 Mar 2024 14:17:09 +0700 Subject: [PATCH] update Dockerfile --- .github/workflows/build_and_push_images.yml | 1 + Dockerfile | 33 ++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_and_push_images.yml b/.github/workflows/build_and_push_images.yml index cbe856e..705d995 100644 --- a/.github/workflows/build_and_push_images.yml +++ b/.github/workflows/build_and_push_images.yml @@ -8,6 +8,7 @@ on: push: branches: - main + pull_request: permissions: contents: read diff --git a/Dockerfile b/Dockerfile index f55a952..e45d550 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,30 @@ -FROM golang:1.21-alpine3.18 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 \ + && 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 + +# Set the working directory WORKDIR /app -COPY go.mod go.sum* ./ - -ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 - -RUN apk add --no-cache $PACKAGES +# 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/.* //') && \ @@ -16,6 +34,7 @@ RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | 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) +# Copy the remaining files COPY . . RUN make build