-
Notifications
You must be signed in to change notification settings - Fork 114
chore: add Linux ARM64 and Windows build targets #2551
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
Closed
NathanFlurry
wants to merge
1
commit into
fix_uncomment_function_type_filter_in_ACTORS_FILTER
from
chore_add_Linux_ARM64_and_Windows_build_targets
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM rust:1.82.0 AS base | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
musl-tools \ | ||
libssl-dev \ | ||
pkg-config \ | ||
protobuf-compiler \ | ||
ca-certificates \ | ||
git-lfs \ | ||
musl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install musl targets | ||
RUN rustup target add aarch64-unknown-linux-musl | ||
|
||
# Set environment variables | ||
ENV CARGO_INCREMENTAL=0 \ | ||
RUSTFLAGS="--cfg tokio_unstable" \ | ||
CARGO_NET_GIT_FETCH_WITH_CLI=true | ||
|
||
# Set working directory | ||
WORKDIR /build | ||
|
||
# Build for aarch64 | ||
FROM base AS aarch64-builder | ||
|
||
# Set up OpenSSL for aarch64 musl target | ||
ENV SSL_VER=1.1.1w | ||
RUN wget https://www.openssl.org/source/openssl-$SSL_VER.tar.gz \ | ||
&& tar -xzf openssl-$SSL_VER.tar.gz \ | ||
&& cd openssl-$SSL_VER \ | ||
&& ./Configure no-shared no-async --prefix=/musl-aarch64 --openssldir=/musl-aarch64/ssl linux-aarch64 \ | ||
&& make -j$(nproc) \ | ||
&& make install_sw \ | ||
&& cd .. \ | ||
&& rm -rf openssl-$SSL_VER* | ||
|
||
# Configure OpenSSL env vars for the build | ||
ENV OPENSSL_DIR=/musl-aarch64 \ | ||
OPENSSL_INCLUDE_DIR=/musl-aarch64/include \ | ||
OPENSSL_LIB_DIR=/musl-aarch64/lib \ | ||
PKG_CONFIG_ALLOW_CROSS=1 | ||
|
||
# Copy the source code | ||
COPY . . | ||
|
||
# Build for Linux with musl (static binary) - aarch64 | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/usr/local/cargo/git \ | ||
--mount=type=cache,target=/build/target \ | ||
cargo build --bin rivet --release --target aarch64-unknown-linux-musl -v && \ | ||
mkdir -p /artifacts && \ | ||
cp target/aarch64-unknown-linux-musl/release/rivet /artifacts/rivet-aarch64-unknown-linux-musl | ||
|
||
# Default command to show help | ||
CMD ["ls", "-la", "/artifacts"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM rust:1.82.0 AS base | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
git-lfs \ | ||
protobuf-compiler \ | ||
clang \ | ||
cmake \ | ||
patch \ | ||
libxml2-dev \ | ||
wget \ | ||
xz-utils \ | ||
curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install osxcross | ||
RUN git config --global --add safe.directory '*' && \ | ||
git clone https://github.com/tpoechtrager/osxcross /root/osxcross && \ | ||
cd /root/osxcross && \ | ||
wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \ | ||
mv MacOSX11.3.sdk.tar.xz tarballs/ && \ | ||
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh | ||
|
||
# Add osxcross to PATH | ||
ENV PATH="/root/osxcross/target/bin:$PATH" | ||
|
||
# Common environment variables for cross-compilation | ||
ENV MACOSX_DEPLOYMENT_TARGET=10.7 \ | ||
# Skip aws-lc-rs with rustls certs config when building for macOS | ||
RUSTFLAGS="--cfg tokio_unstable --cfg rustls_native_certs --cfg aws_lc_rs" \ | ||
CARGO_FEATURE_RUSTLS_NATIVE_CERTS=0 \ | ||
CARGO_RUSTLS_NATIVE_CERTS=0 \ | ||
CARGO_INCREMENTAL=0 \ | ||
CARGO_NET_GIT_FETCH_WITH_CLI=true | ||
|
||
# Set working directory | ||
WORKDIR /build | ||
|
||
# Build for ARM64 macOS | ||
FROM base AS aarch64-builder | ||
|
||
# Install macOS ARM64 target | ||
RUN rustup target add aarch64-apple-darwin | ||
|
||
# Configure Cargo for cross-compilation (ARM64) | ||
RUN mkdir -p /root/.cargo && \ | ||
echo '\ | ||
[target.aarch64-apple-darwin]\n\ | ||
linker = "aarch64-apple-darwin20.4-clang"\n\ | ||
ar = "aarch64-apple-darwin20.4-ar"\n\ | ||
' > /root/.cargo/config.toml | ||
|
||
# Set environment variables for ARM64 cross-compilation | ||
ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=aarch64-apple-darwin20.4-clang \ | ||
CC_aarch64_apple_darwin=aarch64-apple-darwin20.4-clang \ | ||
CXX_aarch64_apple_darwin=aarch64-apple-darwin20.4-clang++ | ||
|
||
# Copy the source code | ||
COPY . . | ||
|
||
# Build for ARM64 macOS | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/usr/local/cargo/git \ | ||
--mount=type=cache,target=/build/target \ | ||
cargo build --bin rivet --release --target aarch64-apple-darwin && \ | ||
mkdir -p /artifacts && \ | ||
cp target/aarch64-apple-darwin/release/rivet /artifacts/rivet-aarch64-apple-darwin | ||
|
||
# Default command to show help | ||
CMD ["ls", "-la", "/artifacts"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: MACOSX_DEPLOYMENT_TARGET=10.7 is very old and may not be appropriate for ARM64 builds which started with macOS 11.0