diff --git a/.github/workflows/price-feeder-docker.yml b/.github/workflows/price-feeder-docker.yml index 1ee3c6aeab..de66a4aa0b 100644 --- a/.github/workflows/price-feeder-docker.yml +++ b/.github/workflows/price-feeder-docker.yml @@ -16,15 +16,14 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2 - + - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: umee-network/price-feeder - tags: - type=semver,pattern=v{{version}} - + tags: type=semver,pattern=v{{version}} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -38,7 +37,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v3 with: - context: ./contrib/images/price-feeder.Dockerfile + context: ./contrib/images/price-feeder.dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/umee-docker.yml b/.github/workflows/umee-docker.yml index 20b7c5e5d1..fb0bf38ca2 100644 --- a/.github/workflows/umee-docker.yml +++ b/.github/workflows/umee-docker.yml @@ -3,10 +3,12 @@ name: Umeed Docker Release on: push: - # Sequence of patterns matched against refs/tags tags: - - "v[0-9]+\\.[0-9]+\\.[0-9]+" # Official release version tags e.g. v2.0.5 - - "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+" # Release candidate tags e.g. v1.0.3-rc4 + - "v[0-9]+\\.[0-9]+\\.[0-9]+" # Push only official release version tags e.g. v2.0.5 + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: umeed-docker: @@ -16,18 +18,28 @@ jobs: - name: checkout uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Docker meta + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v4 with: - images: umee-network/umeed - + # github.repository == / + images: ghcr.io/${{ github.repository_owner }}/umeed + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern=latest-{{major}}.{{minor}} + flavor: | + latest=false + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Print tags and labels + run: | + echo image: ${{ env.REGISTRY }}/${{ github.repository }} + echo tags "${{ steps.meta.outputs.tags }}" + echo labels "${{ steps.meta.outputs.labels }}" + - name: Login to GHCR uses: docker/login-action@v2 with: @@ -38,8 +50,11 @@ jobs: - name: Build and push uses: docker/build-push-action@v3 with: - context: ./contrib/images/umeed.Dockerfile - push: true + file: contrib/images/umeed.dockerfile + platforms: linux/amd64 + # platforms: linux/amd64,linux/arm64 # requires qemu action + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - \ No newline at end of file + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Makefile b/Makefile index 28a1fe272a..f404672be3 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ build: go.sum build-experimental: go.sum @echo "--> Building Experimental version..." EXPERIMENTAL=true $(MAKE) build - + build-no_cgo: @echo "--> Building static binary with no CGO nor GLIBC dynamic linking..." CGO_ENABLED=0 CGO_LDFLAGS="-static" $(MAKE) build @@ -121,7 +121,7 @@ clean: ############################################################################### docker-build: - @docker build -t umeenet/umeed-e2e -f umee.e2e.Dockerfile . + @docker build -t umeenet/umeed-e2e -f contrib/images/umee.e2e.dockerfile . docker-push-hermes: @cd tests/e2e/docker; docker build -t ghcr.io/umee-network/hermes-e2e:latest -f hermes.Dockerfile .; docker push ghcr.io/umee-network/hermes-e2e:latest diff --git a/contrib/images/price-feeder.Dockerfile b/contrib/images/price-feeder.dockerfile similarity index 86% rename from contrib/images/price-feeder.Dockerfile rename to contrib/images/price-feeder.dockerfile index afda1f762e..a64f709652 100644 --- a/contrib/images/price-feeder.Dockerfile +++ b/contrib/images/price-feeder.dockerfile @@ -1,9 +1,9 @@ # Fetch base packages FROM golang:1.19-alpine AS builder -ENV PACKAGES make git libc-dev gcc linux-headers build-base -RUN apk add --no-cache $PACKAGES -WORKDIR /src/app/ +RUN apk add --no-cache make git libc-dev gcc linux-headers build-base +WORKDIR /src/ 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 \ @@ -14,8 +14,7 @@ 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 - -FROM alpine:3.14 +FROM alpine:3.17 RUN apk add bash curl jq COPY --from=builder /go/bin/price-feeder /usr/local/bin/ EXPOSE 7171 diff --git a/umee.e2e.Dockerfile b/contrib/images/umee.e2e.dockerfile similarity index 88% rename from umee.e2e.Dockerfile rename to contrib/images/umee.e2e.dockerfile index 299ed1f9ac..4d8b9c54d5 100644 --- a/umee.e2e.Dockerfile +++ b/contrib/images/umee.e2e.dockerfile @@ -10,9 +10,10 @@ RUN apk add --no-cache $PACKAGES # Compile the umeed binary FROM umee-base-builder AS umeed-builder -WORKDIR /src/app/ -COPY go.mod go.sum* ./ +WORKDIR /src/umee +COPY . . RUN go mod download + # 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 \ @@ -21,23 +22,20 @@ RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) -# Copy the remaining files -COPY . . RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make install RUN cd price-feeder && LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make install # # Fetch peggo (gravity bridge) binary FROM base-builder AS peggo-builder ARG PEGGO_VERSION=v0.3.0 -WORKDIR /downloads/ +WORKDIR /src/peggo RUN git clone https://github.com/umee-network/peggo.git RUN cd peggo && git checkout ${PEGGO_VERSION} && make build && cp ./build/peggo /usr/local/bin/ # Add to a distroless container FROM gcr.io/distroless/cc:debug -COPY --from=umeed-builder /go/bin/umeed /usr/local/bin/ -COPY --from=umeed-builder /go/bin/price-feeder /usr/local/bin/ +COPY --from=umeed-builder /go/bin/* /usr/local/bin/ COPY --from=peggo-builder /usr/local/bin/peggo /usr/local/bin/ -EXPOSE 26656 26657 1317 9090 7171 +EXPOSE 26656 26657 1317 9090 7171 ENTRYPOINT ["umeed", "start"] diff --git a/contrib/images/umeed.Dockerfile b/contrib/images/umeed.Dockerfile deleted file mode 100644 index c02e2727b2..0000000000 --- a/contrib/images/umeed.Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# Fetch base packages -FROM golang:1.19-alpine AS builder -ENV PACKAGES make git libc-dev gcc linux-headers build-base -RUN apk add --no-cache $PACKAGES -WORKDIR /src/app/ -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 && \ - # verify checksum - wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ - sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) -# Build the binary -RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make install - - -FROM alpine:3.14 -RUN apk add bash curl jq -COPY --from=builder /go/bin/umeed /usr/local/bin/ -EXPOSE 26656 26657 1317 9090 -CMD ["umeed", "start"] -STOPSIGNAL SIGTERM diff --git a/contrib/images/umeed.dockerfile b/contrib/images/umeed.dockerfile new file mode 100644 index 0000000000..559c892f64 --- /dev/null +++ b/contrib/images/umeed.dockerfile @@ -0,0 +1,23 @@ +# Stage-1: build +# We use Debian Bullseye rather then Alpine because Alpine has problem building libwasmvm +# - requires to download libwasmvm_muslc from external source. Build with glibc is straightforward. +FROM golang:1.19-bullseye AS builder + +WORKDIR /src/ +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"] +STOPSIGNAL SIGTERM