From 3ad4c05329229e3fb949fc628c8bd2cb57019417 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 11 Oct 2023 10:02:06 -0400 Subject: [PATCH] fix: fix failing Dockerfile for arm architecture --- .github/workflows/realease.yml | 7 ++----- Dockerfile | 17 ++++++----------- Makefile | 21 ++++++++++++--------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.github/workflows/realease.yml b/.github/workflows/realease.yml index 9c141329..d5812a8b 100644 --- a/.github/workflows/realease.yml +++ b/.github/workflows/realease.yml @@ -3,11 +3,8 @@ name: Release on: push: tags: - - "*" - - "v[0-9]+\\.[0-9]+\\.[0-9]+-alpha[0-9]+" # vX.X.X-alphaX - - "v[0-9]+\\.[0-9]+\\.[0-9]+-beta[0-9]+" # vX.X.X-betaX - - "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+" # vX.X.X-rcX - - "v[0-9]+\\.[0-9]+\\.[0-9]+" # vX.X.X + # SemVer regex taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + - "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" concurrency: group: ci-${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true diff --git a/Dockerfile b/Dockerfile index a37d1d8c..69b173ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build-env - +FROM --platform=$BUILDPLATFORM golang:1.21 AS build-env +#FROM golang:1.21 AS build-env # Install minimum necessary dependencies -ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev -RUN apk add --no-cache $PACKAGES +RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu + WORKDIR /go/src/github.com/sedaprotocol/seda-chain @@ -19,17 +19,12 @@ COPY . . # https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide ARG TARGETOS TARGETARCH -RUN if [ "$TARGETARCH" = "arm64" ]; then \ - GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-arm; \ - else \ - RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build; \ - fi - +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build FROM alpine:3 RUN apk add --no-cache curl make bash jq sed -COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/seda-chaid* /usr/bin/seda-chaind +COPY --from=build-env /go/src/github.com/sedaprotocol/seda-chain/build/seda-chaind /usr/bin/seda-chaind EXPOSE 26656 26657 1317 9090 diff --git a/Makefile b/Makefile index 71aecb49..28d55f50 100644 --- a/Makefile +++ b/Makefile @@ -67,20 +67,23 @@ all: tools build lint test ############################################################################### ### Build ### ############################################################################### +BUILD_TARGETS := build install -build: go.sum - CGO_ENABLED=1 go build -mod=readonly $(BUILD_FLAGS) -o build/seda-chaind ./cmd/seda-chaind +build: BUILD_ARGS=-o $(BUILDDIR)/ -build-arm: go.sum - CGO_ENABLED=1 go build -mod=readonly $(BUILD_FLAGS) -o build/seda-chaind-arm ./cmd/seda-chaind +build-linux-amd64: + GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build -build-linux: go.sum - LEDGER_ENABLED=false GOOS=linux CGO_ENABLED=1 go build -mod=readonly $(BUILD_FLAGS) -o build/seda-chaind-linux ./cmd/seda-chaind +build-linux-arm64: + GOOS=linux GOARCH=arm64 LEDGER_ENABLED=false $(MAKE) build -install: go.sum - CGO_ENABLED=1 go install -mod=readonly $(BUILD_FLAGS) ./cmd/seda-chaind +$(BUILD_TARGETS): go.sum $(BUILDDIR)/ + go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... -.PHONY: build install +$(BUILDDIR)/: + mkdir -p $(BUILDDIR)/ + +.PHONY: build build-linux-amd64 build-linux-arm64 ############################################################################### ### Tools & Dependencies ###