Skip to content

Commit

Permalink
fix: fix dockerbuild for arm arch
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios committed Oct 9, 2023
1 parent a3c4930 commit 9cc2fea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine AS build-env
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build-env

# Install minimum necessary dependencies
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev
Expand All @@ -19,14 +19,17 @@ COPY . .
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide
ARG TARGETOS TARGETARCH


RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build

RUN if [ "$TARGETARCH" = "arm64" ]; then \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-arm; \
else \
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build; \
fi

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/cosmos/cosmos-sdk/build/seda-chaid* /usr/bin/seda-chaind

EXPOSE 26656 26657 1317 9090

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ all: tools build lint test
build: go.sum
CGO_ENABLED=1 go build -mod=readonly $(BUILD_FLAGS) -o build/seda-chaind ./cmd/seda-chaind

build-arm: go.sum
CGO_ENABLED=1 go build -mod=readonly $(BUILD_FLAGS) -o build/seda-chaind-arm ./cmd/seda-chaind

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

Expand Down

0 comments on commit 9cc2fea

Please sign in to comment.