From ba0c337f6e07ec044b2467f4f518d7a81a344c88 Mon Sep 17 00:00:00 2001 From: Niccolo Raspa Date: Fri, 20 May 2022 15:51:55 +0200 Subject: [PATCH] Add arm64 support to Docker images (#1541) Closes: #XXX ## What is the purpose of the change This PR extends the work done in #1535 to introduce support for `arm64` architecture making osmosis docker image multi-architecture (`amd64` and `arm64`). I have also updated the CI to build and push the image for multiple architectures. Please note that it takes ~20 minutes for the build complete but it would run only on every new tag so I think it's acceptable. ## Brief Changelog - Modify Dockerfile to add `arm64` support - Update docker CI to build and push for `arm64` ## Testing and Verifying You can build for arm64 with: ```bash docker buildx build --platform linux/arm64 --tag osmosis:arm64 . ``` I tested the CI in my fork: https://github.com/nikever/osmosis/runs/6505857265?check_suite_focus=true ## Documentation and Release Note - Does this pull request introduce a new feature or user-facing behavior changes? yes (`arm64` support!) - Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? yes - How is the feature or change documented? not applicable --- .github/workflows/docker.yml | 3 ++- CHANGELOG.md | 1 + Dockerfile | 29 ++++++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8f51f8a5d0e..955bd5fe19d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -44,8 +44,9 @@ jobs: file: Dockerfile context: . push: true - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e7cf561f2aa..b815fadd4c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1253] Add lockup duration edit method * [#1312] Stableswap: Createpool logic * [#1230] Stableswap CFMM equations +* [#1541] Add arm64 support to Docker ## [v8.0.0 - Emergency proposals upgrade](https://github.com/osmosis-labs/osmosis/releases/tag/v8.0.0) diff --git a/Dockerfile b/Dockerfile index 5fc92efd277..7bfa136b2b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,36 @@ # syntax=docker/dockerfile:1 -ARG BASE_IMG_TAG=nonroot +ARG BASE_IMG_TAG=nonroot + +# -------------------------------------------------------- +# Build +# -------------------------------------------------------- -## Build Image FROM golang:1.18.2-alpine3.15 as build RUN set -eux; apk add --no-cache ca-certificates build-base; - RUN apk add git - -# needed by github.com/zondax/hid +# Needed by github.com/zondax/hid RUN apk add linux-headers WORKDIR /osmosis COPY . /osmosis -# From https://github.com/CosmWasm/wasmd/blob/master/Dockerfile -# For more details see https://github.com/CosmWasm/wasmvm#builds-of-libwasmvm -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a -RUN sha256sum /lib/libwasmvm_muslc.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 +# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a +RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc +RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 + +# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` +RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build -## Deploy image +# -------------------------------------------------------- +# Runner +# -------------------------------------------------------- + FROM gcr.io/distroless/base-debian11:${BASE_IMG_TAG} COPY --from=build /osmosis/build/osmosisd /bin/osmosisd @@ -35,4 +43,3 @@ EXPOSE 26657 EXPOSE 1317 ENTRYPOINT ["osmosisd"] -CMD [ "start" ] \ No newline at end of file