Skip to content

Commit 8b9d863

Browse files
committed
chore: switch to building toolchain with dockerfiles instead of github actions
1 parent 528ebcb commit 8b9d863

9 files changed

Lines changed: 365 additions & 119 deletions

File tree

.github/workflows/release.yaml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ jobs:
9090
runner: [self-hosted, Linux, X64]
9191
suffix: x86-linux
9292
target: x86_64-unknown-linux-gnu
93-
# - platform: windows
94-
# runner: [self-hosted, Linux, X64]
95-
# suffix: x86-windows.exe
96-
# target: x86_64-pc-windows-gnu
97-
- platform: macos
93+
arch: x86
94+
- platform: windows
95+
runner: [self-hosted, Linux, X64]
96+
suffix: x86-windows.exe
97+
target: x86_64-pc-windows-gnu
98+
arch: x86
99+
- platform: mac
98100
runner: [self-hosted, Linux, X64]
99101
suffix: x86-mac
100102
target: x86_64-apple-darwin
101-
- platform: macos
103+
arch: x86
104+
- platform: mac
102105
runner: [self-hosted, Linux, ARM64]
103106
suffix: aarch64-mac
104107
target: aarch64-apple-darwin
@@ -117,15 +120,8 @@ jobs:
117120
# Use Docker BuildKit
118121
export DOCKER_BUILDKIT=1
119122
120-
# Build the binary using our Dockerfile
121-
ARCH_ARG="${{ matrix.arch }}"
122-
if [ -n "$ARCH_ARG" ]; then
123-
# For ARM64 macOS
124-
docker/toolchain/build.sh ${{ matrix.platform }} $ARCH_ARG
125-
else
126-
# For other platforms
127-
docker/toolchain/build.sh ${{ matrix.platform }}
128-
fi
123+
# Build the binary
124+
scripts/toolchain/build-cross.sh ${{ matrix.platform }} ${{ matrix.arch }}
129125
130126
# Make sure dist directory exists and binary is there
131127
ls -la dist/
@@ -323,4 +319,4 @@ jobs:
323319
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --completeCi
324320
else
325321
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --completeCi
326-
fi
322+
fi

docker/toolchain/build.sh

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# syntax=docker/dockerfile:1.4
2+
FROM rust:1.82.0
3+
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
musl-tools \
7+
libssl-dev \
8+
pkg-config \
9+
protobuf-compiler \
10+
ca-certificates \
11+
git-lfs \
12+
musl-dev \
13+
gcc-aarch64-linux-gnu \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Install musl target for aarch64
17+
RUN rustup target add aarch64-unknown-linux-musl
18+
19+
# Set up OpenSSL for musl target
20+
ENV SSL_VER=1.1.1w
21+
RUN wget https://www.openssl.org/source/openssl-$SSL_VER.tar.gz \
22+
&& tar -xzf openssl-$SSL_VER.tar.gz \
23+
&& cd openssl-$SSL_VER \
24+
&& ./Configure no-shared no-async --prefix=/musl-aarch64 --openssldir=/musl-aarch64/ssl linux-aarch64 \
25+
&& make -j$(nproc) CC=aarch64-linux-gnu-gcc \
26+
&& make install_sw \
27+
&& cd .. \
28+
&& rm -rf openssl-$SSL_VER*
29+
30+
# Configure OpenSSL env vars for the build
31+
ENV OPENSSL_DIR=/musl-aarch64 \
32+
OPENSSL_INCLUDE_DIR=/musl-aarch64/include \
33+
OPENSSL_LIB_DIR=/musl-aarch64/lib \
34+
PKG_CONFIG_ALLOW_CROSS=1 \
35+
CC_aarch64_unknown_linux_musl=aarch64-linux-gnu-gcc \
36+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc
37+
38+
# Set environment variables
39+
ENV CARGO_INCREMENTAL=0 \
40+
RUSTFLAGS="--cfg tokio_unstable" \
41+
CARGO_NET_GIT_FETCH_WITH_CLI=true
42+
43+
# Set working directory
44+
WORKDIR /build
45+
46+
# Build CLI instructions
47+
COPY . .
48+
49+
# Build for Linux with musl (static binary)
50+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
51+
--mount=type=cache,target=/usr/local/cargo/git \
52+
--mount=type=cache,target=/build/target \
53+
cargo build --bin rivet --release --target aarch64-unknown-linux-musl -v && \
54+
mkdir -p /artifacts && \
55+
cp target/aarch64-unknown-linux-musl/release/rivet /artifacts/rivet-aarch64-linux
56+
57+
# Default command to show help
58+
CMD ["ls", "-la", "/artifacts"]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# syntax=docker/dockerfile:1.4
2+
FROM rust:1.82.0
3+
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
musl-tools \
7+
libssl-dev \
8+
pkg-config \
9+
protobuf-compiler \
10+
ca-certificates \
11+
git-lfs \
12+
musl-dev \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Install musl target
16+
RUN rustup target add x86_64-unknown-linux-musl
17+
18+
# Set up OpenSSL for musl target
19+
ENV SSL_VER=1.1.1w
20+
RUN wget https://www.openssl.org/source/openssl-$SSL_VER.tar.gz \
21+
&& tar -xzf openssl-$SSL_VER.tar.gz \
22+
&& cd openssl-$SSL_VER \
23+
&& ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64 \
24+
&& make -j$(nproc) \
25+
&& make install_sw \
26+
&& cd .. \
27+
&& rm -rf openssl-$SSL_VER*
28+
29+
# Configure OpenSSL env vars for the build
30+
ENV OPENSSL_DIR=/musl \
31+
OPENSSL_INCLUDE_DIR=/musl/include \
32+
OPENSSL_LIB_DIR=/musl/lib \
33+
PKG_CONFIG_ALLOW_CROSS=1
34+
35+
# Set environment variables
36+
ENV CARGO_INCREMENTAL=0 \
37+
RUSTFLAGS="--cfg tokio_unstable" \
38+
CARGO_NET_GIT_FETCH_WITH_CLI=true
39+
40+
# Set working directory
41+
WORKDIR /build
42+
43+
# Build CLI instructions
44+
COPY . .
45+
46+
# Build for Linux with musl (static binary)
47+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
48+
--mount=type=cache,target=/usr/local/cargo/git \
49+
--mount=type=cache,target=/build/target \
50+
cargo build --bin rivet --release --target x86_64-unknown-linux-musl -v && \
51+
mkdir -p /artifacts && \
52+
cp target/x86_64-unknown-linux-musl/release/rivet /artifacts/rivet-x86-linux
53+
54+
# Default command to show help
55+
CMD ["ls", "-la", "/artifacts"]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# syntax=docker/dockerfile:1.4
2+
FROM rust:1.82.0
3+
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
git-lfs \
7+
protobuf-compiler \
8+
clang \
9+
cmake \
10+
patch \
11+
libxml2-dev \
12+
wget \
13+
xz-utils \
14+
curl \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Install osxcross
18+
RUN git config --global --add safe.directory '*' && \
19+
git clone https://github.com/tpoechtrager/osxcross /root/osxcross && \
20+
cd /root/osxcross && \
21+
wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \
22+
mv MacOSX11.3.sdk.tar.xz tarballs/ && \
23+
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
24+
25+
# Add osxcross to PATH
26+
ENV PATH="/root/osxcross/target/bin:$PATH"
27+
28+
# Install macOS target
29+
RUN rustup target add aarch64-apple-darwin
30+
31+
# Configure Cargo for cross-compilation
32+
RUN mkdir -p /root/.cargo && \
33+
echo '\
34+
[target.aarch64-apple-darwin]\n\
35+
linker = "aarch64-apple-darwin20.4-clang"\n\
36+
ar = "aarch64-apple-darwin20.4-ar"\n\
37+
' > /root/.cargo/config.toml
38+
39+
# Set environment variables for cross-compilation
40+
ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=aarch64-apple-darwin20.4-clang \
41+
CC_aarch64_apple_darwin=aarch64-apple-darwin20.4-clang \
42+
CXX_aarch64_apple_darwin=aarch64-apple-darwin20.4-clang++ \
43+
MACOSX_DEPLOYMENT_TARGET=10.7 \
44+
# Skip aws-lc-rs with rustls certs config when building for macOS
45+
RUSTFLAGS="--cfg tokio_unstable --cfg rustls_native_certs --cfg aws_lc_rs" \
46+
CARGO_FEATURE_RUSTLS_NATIVE_CERTS=0 \
47+
CARGO_RUSTLS_NATIVE_CERTS=0 \
48+
CARGO_INCREMENTAL=0 \
49+
CARGO_NET_GIT_FETCH_WITH_CLI=true
50+
51+
# Set working directory
52+
WORKDIR /build
53+
54+
# Copy the source code
55+
COPY . .
56+
57+
# Build for ARM64 macOS
58+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
59+
--mount=type=cache,target=/usr/local/cargo/git \
60+
--mount=type=cache,target=/build/target \
61+
cargo build --bin rivet --release --target aarch64-apple-darwin && \
62+
mkdir -p /artifacts && \
63+
cp target/aarch64-apple-darwin/release/rivet /artifacts/rivet-aarch64-mac
64+
65+
# Default command to show help
66+
CMD ["ls", "-la", "/artifacts"]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# syntax=docker/dockerfile:1.4
2+
FROM rust:1.82.0
3+
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
git-lfs \
7+
protobuf-compiler \
8+
clang \
9+
cmake \
10+
patch \
11+
libxml2-dev \
12+
wget \
13+
xz-utils \
14+
curl \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Install osxcross
18+
RUN git config --global --add safe.directory '*' && \
19+
git clone https://github.com/tpoechtrager/osxcross /root/osxcross && \
20+
cd /root/osxcross && \
21+
wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \
22+
mv MacOSX11.3.sdk.tar.xz tarballs/ && \
23+
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
24+
25+
# Add osxcross to PATH
26+
ENV PATH="/root/osxcross/target/bin:$PATH"
27+
28+
# Install macOS target
29+
RUN rustup target add x86_64-apple-darwin
30+
31+
# Configure Cargo for cross-compilation
32+
RUN mkdir -p /root/.cargo && \
33+
echo '\
34+
[target.x86_64-apple-darwin]\n\
35+
linker = "x86_64-apple-darwin20.4-clang"\n\
36+
ar = "x86_64-apple-darwin20.4-ar"\n\
37+
' > /root/.cargo/config.toml
38+
39+
# Set environment variables for cross-compilation
40+
ENV CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=x86_64-apple-darwin20.4-clang \
41+
CC_x86_64_apple_darwin=x86_64-apple-darwin20.4-clang \
42+
CXX_x86_64_apple_darwin=x86_64-apple-darwin20.4-clang++ \
43+
MACOSX_DEPLOYMENT_TARGET=10.7 \
44+
# Skip aws-lc-rs with rustls certs config when building for macOS
45+
RUSTFLAGS="--cfg tokio_unstable --cfg rustls_native_certs --cfg aws_lc_rs" \
46+
CARGO_FEATURE_RUSTLS_NATIVE_CERTS=0 \
47+
CARGO_RUSTLS_NATIVE_CERTS=0 \
48+
CARGO_INCREMENTAL=0 \
49+
CARGO_NET_GIT_FETCH_WITH_CLI=true
50+
51+
# Set working directory
52+
WORKDIR /build
53+
54+
# Copy the source code
55+
COPY . .
56+
57+
# Build for x86_64 macOS
58+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
59+
--mount=type=cache,target=/usr/local/cargo/git \
60+
--mount=type=cache,target=/build/target \
61+
cargo build --bin rivet --release --target x86_64-apple-darwin && \
62+
mkdir -p /artifacts && \
63+
cp target/x86_64-apple-darwin/release/rivet /artifacts/rivet-x86-mac
64+
65+
# Default command to show help
66+
CMD ["ls", "-la", "/artifacts"]

0 commit comments

Comments
 (0)