Skip to content

Commit

Permalink
fix: fix failing Dockerfile for arm architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios committed Oct 11, 2023
1 parent 9cc2fea commit d094123
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/realease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build-env

#FROM --platform=$BUILDPLATFORM golang:1.21-alpine 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
Expand All @@ -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

Expand Down
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down

0 comments on commit d094123

Please sign in to comment.