Skip to content

Commit

Permalink
Add arm64 support to Docker images (#1541)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Niccolo Raspa committed May 20, 2022
1 parent 583cfec commit ba0c337
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
29 changes: 18 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -35,4 +43,3 @@ EXPOSE 26657
EXPOSE 1317

ENTRYPOINT ["osmosisd"]
CMD [ "start" ]

0 comments on commit ba0c337

Please sign in to comment.