Skip to content

Commit

Permalink
Merge pull request #923 from public-awesome/tasiov/docker-build-arm
Browse files Browse the repository at this point in the history
Build stargaze docker image using buildx
  • Loading branch information
jhernandezb authored Nov 16, 2023
2 parents 6c6cfb7 + f438c3c commit d285c84
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 20 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,33 @@ FROM golang:1.21.3-alpine3.17 AS go-builder

RUN set -eux; apk add --no-cache ca-certificates build-base git;

# TARGETPLATFORM build argument provided by buildx: e.g., linux/amd64, linux/arm64. etc.
ARG TARGETPLATFORM=linux/amd64

# NOTE: add these to run with LEDGER_ENABLED=true
# RUN apk add libusb-dev linux-headers

WORKDIR /code
COPY . /code/

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a
RUN echo "465e3a088e96fd009a11bfd234c69fb8a0556967677e54511c084f815cf9ce63 /lib/libwasmvm_muslc.a" | sha256sum -c
# Download the correct version of libwasmvm for the given platform and verify checksum
RUN case "${TARGETPLATFORM}" in \
"linux/amd64") \
WASMVM_URL="https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.x86_64.a" && \
WASMVM_CHECKSUM="465e3a088e96fd009a11bfd234c69fb8a0556967677e54511c084f815cf9ce63" \
;; \
"linux/arm64") \
WASMVM_URL="https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.aarch64.a" && \
WASMVM_CHECKSUM="2687afbdae1bc6c7c8b05ae20dfb8ffc7ddc5b4e056697d0f37853dfe294e913" \
;; \
*) \
echo "Unsupported platform: ${TARGETPLATFORM}" ; \
exit 1 \
;; \
esac && \
wget "${WASMVM_URL}" -O /lib/libwasmvm_muslc.a && \
echo "${WASMVM_CHECKSUM} /lib/libwasmvm_muslc.a" | sha256sum -c

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ full-lint: lint
build-linux:
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build $(BUILD_FLAGS) -o bin/starsd github.com/public-awesome/stargaze/cmd/starsd

build-docker-arm:
docker buildx build --platform linux/arm64 --load .

build-docker:
docker build -t publicawesome/stargaze:local-dev .
docker buildx build --platform linux/amd64 --load .

docker-test: build-linux
docker build -f docker/Dockerfile.test -t rocketprotocol/stargaze-relayer-test:latest .
Expand Down

0 comments on commit d285c84

Please sign in to comment.