Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arm64 builds #45

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add rust-base target -- an image sans SGX SDKs for building clients o…
…n non-intel platforms
holtzman committed Oct 8, 2024
commit 24e7eb070a8dbea65e464a25de43d6f417631538
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright (c) 2022 MobileCoin Inc.
FROM ubuntu:focal-20230126 as rust-sgx-base
# Copyright (c) 2022 to 2024 MobileCoin Inc.
# build with --build-arg BUILDER_INSTALL_BASE=rust-base to leave out SGX, e.g. for
# building clients and libraries on non-intel platforms
ARG BUILDER_INSTALL_BASE=rust-sgx-base
FROM ubuntu:focal-20230126 AS rust-base

SHELL ["/bin/bash", "-c"]

@@ -51,6 +54,19 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.2/pro
&& cp -r protoc/include/google /usr/include/google \
&& rm -rf protoc

# Github actions overwrites the runtime home directory, so we need to install in a global directory.
ENV RUSTUP_HOME=/opt/rustup
ENV CARGO_HOME=/opt/cargo
RUN mkdir -p ${RUSTUP_HOME} \
&& mkdir -p ${CARGO_HOME}/bin

# Install rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain nightly-2023-10-01

ENV PATH=/opt/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

FROM rust-base AS rust-sgx-base
# Install SGX
ARG SGX_URL=https://download.01.org/intel-sgx/sgx-linux/2.23/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.23.100.2.bin
RUN curl -o sgx.bin "${SGX_URL}" \
@@ -73,22 +89,12 @@ RUN mkdir -p /etc/apt/keyrings \
&& rm -r /var/lib/apt/lists

ENV SGX_SDK=/opt/intel/sgxsdk
ENV PATH=/opt/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/intel/sgxsdk/bin:/opt/intel/sgxsdk/bin/x64
ENV PATH=${PATH}:/opt/intel/sgxsdk/bin:/opt/intel/sgxsdk/bin/x64
ENV PKG_CONFIG_PATH=/opt/intel/sgxsdk/pkgconfig
ENV LD_LIBRARY_PATH=/opt/intel/sgxsdk/sdk_libs

# Github actions overwrites the runtime home directory, so we need to install in a global directory.
ENV RUSTUP_HOME=/opt/rustup
ENV CARGO_HOME=/opt/cargo
RUN mkdir -p ${RUSTUP_HOME} \
&& mkdir -p ${CARGO_HOME}/bin

# Install rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain nightly-2023-10-01

# Set up the builder-install image with more test helpers for CI.
FROM rust-sgx-base AS builder-install
FROM ${BUILDER_INSTALL_BASE} AS builder-install

SHELL ["/bin/bash", "-c"]

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ We recommend referencing the image by the hash instead of a tag to verify a cons
The following command will build and tag `rust-sgx-base:latest`. (But not push it to dockerhub, the tag will be local to your machine.)

```
docker build -t mobilecoin/rust-sgx-base .
docker build -t mobilecoin/rust-sgx-base --target rust-sgx-base .
```

This variation will build and tag `builder-install:latest`.
@@ -19,6 +19,12 @@ This variation will build and tag `builder-install:latest`.
docker build -t mobilecoin/builder-install .
```

A third variation is available, `rust-base`, which does not include the SGX SDKs. This facilitates building blockchain clients on non-intel architectures, e.g. linux/arm64.

```
docker build -t mobilecoin/rust-base --target rust-base .
```

To help iterate on a `builder-install` image, you can test it by opening a prompt
using the [`mob prompt` tool in `mobilecoin`](https://github.com/mobilecoinfoundation/mobilecoin/blob/master/mob).
Then you can try to build rust code, or go code, or really whatever your heart desires.