mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Thoroughly update versions and methodology
For hash-pinned dependencies, adds comments documenting the associated versions. Adds a pin to `slither-analyzer` which was prior missing. Updates to Monero 0.18.4.4. `mimalloc` now has the correct option set when building for `musl`. A C++ compiler is no longer required in its Docker image. The runtime's `Dockerfile` now symlinks a `libc.so` already present on the image instead of creating one itself. It also builds the runtime within the image to ensure it only happens once. The test to ensure the methodology is reproducible has been updated to not simply create containers from the image, yet rebuild the image entirely, accordingly. This also is more robust and arguably should have already been done. The pin to the exact hash of the `patch-polkadot-sdk` repo in every `Cargo.toml` has been removed. The lockfile already serves that role, simplifying updating in the future. The latest Rust nightly is adopted as well (superseding https://github.com/serai-dex/serai/pull/697). The `librocksdb-sys` patch is replaced with a `kvdb-rocksdb` patch, removing a git dependency, thanks to https://github.com/paritytech/parity-common/pull/950.
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
#check=skip=FromPlatformFlagConstDisallowed
|
||||
# We want to explicitly set the platform to ensure a constant host environment
|
||||
|
||||
# rust:1.91.1-alpine as of November 11th, 2025 (GMT)
|
||||
FROM --platform=linux/amd64 rust@sha256:700c0959b23445f69c82676b72caa97ca4359decd075dca55b13339df27dc4d3 AS deterministic
|
||||
FROM --platform=linux/amd64 rust@sha256:700c0959b23445f69c82676b72caa97ca4359decd075dca55b13339df27dc4d3
|
||||
|
||||
# Add the wasm toolchain
|
||||
# In order to compile the runtime, including the `proc-macro`s and build scripts, we need the
|
||||
# required development libraries. These are traditionally provided by `musl-dev` which is not
|
||||
# inherently included with this image (https://github.com/rust-lang/docker-rust/issues/68). While we
|
||||
# could install it here, we'd be unable to pin the installed package by its hash as desired.
|
||||
#
|
||||
# Rust does have self-contained libraries, intended to be used when the desired development files
|
||||
# are not otherwise available. These can be enabled with `link-self-contained=yes`. Unfortunately,
|
||||
# this doesn't work here (https://github.com/rust-lang/rust/issues/149371).
|
||||
#
|
||||
# While we can't set `link-self-contained=yes`, we can install Rust's self-contained libraries onto
|
||||
# our system so they're generally available.
|
||||
RUN echo '#!/bin/sh' > libs.sh
|
||||
RUN echo 'set -e' >> libs.sh
|
||||
RUN echo 'SYSROOT=$(rustc --print sysroot)' >> libs.sh
|
||||
RUN echo 'LIBS=$SYSROOT/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained' >> libs.sh
|
||||
RUN echo 'ln -s $LIBS/Scrt1.o $LIBS/crti.o $LIBS/crtn.o /usr/lib' >> libs.sh
|
||||
# We also need `libc.so` which is already present on the system, just not under that name
|
||||
RUN echo 'ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.so' >> libs.sh
|
||||
RUN /bin/sh ./libs.sh
|
||||
|
||||
# Add the WASM toolchain
|
||||
RUN rustup target add wasm32v1-none
|
||||
|
||||
FROM deterministic
|
||||
|
||||
# Add files for build
|
||||
ADD patches /serai/patches
|
||||
ADD common /serai/common
|
||||
@@ -25,32 +46,8 @@ ADD AGPL-3.0 /serai
|
||||
|
||||
WORKDIR /serai
|
||||
|
||||
# `proc-macro`s are difficult here on Alpine, with `musl`. Rust expects to be able to build the
|
||||
# `proc-macro`s into dynamic libraries, which requires setting `target-feature=-crt-static`
|
||||
# (disabling static linking). This will become the default at some point in the future
|
||||
# (https://github.com/rust-lang/compiler-time/issues/422).
|
||||
#
|
||||
# While this is fine, Rust/musl will expect to be able to link `crti.o` into the built
|
||||
# `proc-macro`s. `crti.o` would be provided by the `musl-dev` package which Rust's docker images do
|
||||
# not include by default (https://github.com/rust-lang/docker-rust/issues/68). While we could add it
|
||||
# ourselves, we cannot do so _while pinning by a hash_. We'd have to pin it by its version tag.
|
||||
#
|
||||
# Rust does provide `crti.o` as part of its self-contained builds. We cannot use
|
||||
# `link-self-contained=yes` here however, as that would link `musl` into the `proc-macro`s and
|
||||
# `musl` may only be linked once into a running program
|
||||
# (https://github.com/rust-lang/rust/issues/149371).
|
||||
#
|
||||
# While we can't use self-contained builds, we can use the libraries shipped for self-contained
|
||||
# builds. We do so here, adding Rust's libraries to the linker's search path, making `crti.o`
|
||||
# available without adding `musl-dev`.
|
||||
RUN echo 'SYSROOT=$(rustc --print sysroot)' >> libs.sh
|
||||
RUN echo 'LIBS=$SYSROOT/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained' >> libs.sh
|
||||
RUN echo 'ln -s $LIBS/Scrt1.o $LIBS/crti.o $LIBS/crtn.o /usr/lib' >> libs.sh
|
||||
# For `libc`, we need a shared library, not a static archive, so we convert it now
|
||||
RUN echo 'gcc -shared -o /usr/lib/libc.so -L$LIBS -Wl,--whole-archive -lc -Wl,--no-whole-archive -nodefaultlibs' >> libs.sh
|
||||
RUN /bin/sh ./libs.sh
|
||||
# Build the runtime
|
||||
RUN cargo build --release -p serai-runtime
|
||||
|
||||
ENV RUSTFLAGS="-Ctarget-feature=-crt-static"
|
||||
CMD cargo build --release -p serai-runtime && \
|
||||
mkdir -p /volume && \
|
||||
cp /serai/target/release/wbuild/serai-runtime/serai_runtime.wasm /volume/serai.wasm
|
||||
# Copy the runtime to the provided volume
|
||||
CMD ["cp", "/serai/target/release/wbuild/serai-runtime/serai_runtime.wasm", "/volume/serai.wasm"]
|
||||
|
||||
Reference in New Issue
Block a user