Skip to content

Commit

Permalink
chore: update docker to support wasmvm (#120)
Browse files Browse the repository at this point in the history
Co-authored-by: Anil K <[email protected]>
  • Loading branch information
jim380 and anilcse committed Oct 16, 2023
1 parent a89b65b commit 480a08a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 32 deletions.
47 changes: 15 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
# Simple usage with a mounted data directory:
# > docker build -t simapp .
#
# Server:
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simapp:/root/.simapp simapp simd init test-chain
# TODO: need to set validator in genesis so start runs
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simapp:/root/.simapp simapp simd start
#
# Client: (Note the simapp binary always looks at ~/.simapp we can bind to different local storage)
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys add foo
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys list
# TODO: demo connecting rest-server (or is this in server now?)
FROM golang:alpine AS build-env

# Install minimum necessary dependencies,
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
RUN apk add --no-cache $PACKAGES

# Set working directory for the build
WORKDIR /go/src/github.com/cosmos/cosmos-sdk

# Add source files
FROM golang:1.20.5-alpine AS build-env

# Set up dependencies
ENV PACKAGES bash curl make git libc-dev gcc linux-headers eudev-dev python3

# ADD . /code
WORKDIR /code

COPY . .

# install simapp, remove packages
RUN make build-linux
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a

RUN apk add --no-cache $PACKAGES && \
BUILD_TAGS=muslc LINK_STATICALLY=true make install && \
rm -rf /var/cache/apk/*

# Final image
FROM alpine:edge

# Install ca-certificates
RUN apk add --update ca-certificates
WORKDIR /root

# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/simd /usr/bin/simd
WORKDIR /code

EXPOSE 26656 26657 1317 9090
COPY --from=build-env /go/bin/passage /usr/local/bin/passage

# Run simd by default, omit entrypoint to ease using container with simcli
CMD ["simd"]
CMD ["passage"]
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

Expand Down

0 comments on commit 480a08a

Please sign in to comment.