Skip to content

Commit

Permalink
perf: optimize docker builds (#1708)
Browse files Browse the repository at this point in the history
## Description

closes: #1697

---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] added appropriate labels to the PR
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

_All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items._

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
robert-zaremba authored Jan 11, 2023
1 parent 869fb0d commit 461c0dd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
13 changes: 10 additions & 3 deletions contrib/images/price-feeder.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Fetch base packages
FROM golang:1.19-alpine AS builder
RUN apk add --no-cache make git libc-dev gcc linux-headers build-base

WORKDIR /src/
# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./
RUN go mod download

COPY . .

# Cosmwasm - Download correct libwasmvm version
Expand All @@ -14,9 +19,11 @@ RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) &&
# Build the binary
RUN cd price-feeder && LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make install

## Prepare the final clear binary
FROM alpine:3.17
RUN apk add bash curl jq
COPY --from=builder /go/bin/price-feeder /usr/local/bin/
EXPOSE 7171
CMD ["price-feeder"]
STOPSIGNAL SIGTERM
CMD ["price-feeder"]

RUN apk add ca-certificates
COPY --from=builder /go/bin/price-feeder /usr/local/bin/
14 changes: 9 additions & 5 deletions contrib/images/umee.e2e-static.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
# umeed, price-feeder, peggo

FROM golang:1.19-alpine AS builder
ENV PACKAGES make git gcc linux-headers ca-certificates build-base curl
ENV PACKAGES make git gcc linux-headers build-base curl
RUN apk add --no-cache $PACKAGES

## Build umeed
WORKDIR /src/umee
COPY . .
# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./
RUN go mod download

COPY . .
# Cosmwasm - Download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a -O /lib/libwasmvm_muslc.a && \
Expand All @@ -31,9 +34,10 @@ RUN cd /src/peggo; BUILD_TAGS=muslc LDFLAGS='-linkmode=external -extldflags "-Wl

## Prepare the final clear binary
FROM alpine:latest
EXPOSE 26656 26657 1317 9090 7171
ENTRYPOINT ["umeed", "start"]

# no need to copy libwasmvm_muslc.a because we created static
COPY --from=builder /go/bin/* /usr/local/bin/
COPY --from=builder /src/peggo/build/peggo /usr/local/bin/

EXPOSE 26656 26657 1317 9090 7171
ENTRYPOINT ["umeed", "start"]
RUN apk add ca-certificates
11 changes: 7 additions & 4 deletions contrib/images/umee.e2e.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ FROM golang:1.19-bullseye AS builder

## Build umeed
WORKDIR /src/umee
COPY . .
# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN make install && \
cd price-feeder && make install

Expand All @@ -20,10 +23,10 @@ RUN wget https://github.com/umee-network/peggo/releases/download/v1.4.0/peggo-v1

## Prepare the final clear binary
FROM ubuntu:rolling
EXPOSE 26656 26657 1317 9090 7171
ENTRYPOINT ["umeed", "start"]

COPY --from=builder /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm\@v*/internal/api/libwasmvm.*.so /usr/lib/
COPY --from=builder /go/bin/* /usr/local/bin/
COPY --from=builder /src/peggo-v*/peggo /usr/local/bin/
RUN apt-get update && apt-get install ca-certificates -y

EXPOSE 26656 26657 1317 9090 7171
ENTRYPOINT ["umeed", "start"]
15 changes: 9 additions & 6 deletions contrib/images/umeed.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
FROM golang:1.19-bullseye AS builder

WORKDIR /src/
COPY . .
# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN LEDGER_ENABLED=false BUILD_TAGS=badgerdb make install


# Stage-2: copy binary and required artifacts to a fresh image
# we need to use debian compatible system.
FROM ubuntu:rolling
# RUN apt update && apt upgrade -y ca-certificates
COPY --from=builder /go/bin/umeed /usr/local/bin/
COPY --from=builder /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm\@v*/internal/api/libwasmvm.*.so /usr/lib/

EXPOSE 26656 26657 1317 9090
# Run umeed by default, omit entrypoint to ease using container with CLI
CMD ["umeed"]
# Run umeed by default, omit entrypoint to ease using container with CLI
STOPSIGNAL SIGTERM

RUN apt-get update && apt-get install ca-certificates -y
COPY --from=builder /go/bin/umeed /usr/local/bin/
COPY --from=builder /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm\@v*/internal/api/libwasmvm.*.so /usr/lib/
2 changes: 1 addition & 1 deletion x/leverage/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewMsgUpdateRegistry(authority, title, description string, updateTokens, ad
}
}

// Type implements Msg
// Type implements Msg interface
func (msg MsgGovUpdateRegistry) Type() string { return sdk.MsgTypeURL(&msg) }

// String implements the Stringer interface.
Expand Down

0 comments on commit 461c0dd

Please sign in to comment.