Windows reproducible builds using Docker
This commit is contained in:
parent
43ece74cf7
commit
89d2e67625
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
*
|
||||
!gui/Cargo.*
|
||||
!contrib/docker/cargo_config.toml
|
||||
46
contrib/docker/Dockerfile
Normal file
46
contrib/docker/Dockerfile
Normal file
@ -0,0 +1,46 @@
|
||||
FROM debian:bullseye
|
||||
|
||||
WORKDIR /liana
|
||||
|
||||
# We try to pin our dependencies to avoid potential sources of non-determinism, but we don't go
|
||||
# out of our way to pin the whole tree of deps. Instead invest time in getting Guix cross-compilation.
|
||||
RUN apt update && apt install -y \
|
||||
gcc-mingw-w64-x86-64=10.2.1-6+24.2 \
|
||||
curl=7.74.0-1.3+deb11u3 \
|
||||
gcc=4:10.2.1-1
|
||||
|
||||
# Download the cargo binary and compiled stdlib from the distributed releases to make sure to build with
|
||||
# the very same toolchain. We use 1.65.0 because it is unfortunately the MSRV of the GUI.
|
||||
RUN curl -O "https://static.rust-lang.org/dist/rust-1.65.0-x86_64-unknown-linux-gnu.tar.gz" && \
|
||||
echo "8f754fdd5af783fe9020978c64e414cb45f3ad0a6f44d045219bbf2210ca3cb9 rust-1.65.0-x86_64-unknown-linux-gnu.tar.gz" | sha256sum -c && \
|
||||
tar -xzf rust-1.65.0-x86_64-unknown-linux-gnu.tar.gz && \
|
||||
curl -O "https://static.rust-lang.org/dist/rust-1.65.0-x86_64-pc-windows-gnu.tar.gz" && \
|
||||
echo "eaa0d89511739c16d2a6149ed3538ce10596c523c4791b4a378dde762cda77e4 rust-1.65.0-x86_64-pc-windows-gnu.tar.gz" | sha256sum -c && \
|
||||
tar -xzf rust-1.65.0-x86_64-pc-windows-gnu.tar.gz && \
|
||||
rm -r *.tar.gz
|
||||
|
||||
# Copy the Cargo files to vendor the dependencies.
|
||||
COPY gui/Cargo.toml gui/Cargo.lock /liana/
|
||||
|
||||
# We cache the dependencies sources in the image to avoid re-indexing everything from scratch
|
||||
# at every run. It was useful when debugging the build, it could be removed eventually if we
|
||||
# think the tradeoff vs the image size wasn't worth it anymore.
|
||||
RUN /liana/rust-1.65.0-x86_64-unknown-linux-gnu/cargo/bin/cargo vendor
|
||||
|
||||
# Cargo configuration for using the vendored dependencies during the build.
|
||||
COPY contrib/docker/cargo_config.toml /liana/.cargo/cargo_config.toml
|
||||
|
||||
# For some reason, we can't just set the RUSTFLAGS environment variable to add `-L` for compiling dependencies.
|
||||
# This doesn't work: RUSTFLAGS="-L /liana/rust-1.65.0-x86_64-pc-windows-gnu/rust-std-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/ -L /liana/rust-1.65.0-x86_64-unknown-linux-gnu/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/"
|
||||
# As a workaround, we use a wrapped `rustc` binary that always links against the windows stdlib we just downloaded.
|
||||
# Some issues that seem to be related:
|
||||
# https://github.com/rust-lang/rust/issues/40717
|
||||
# https://github.com/rust-lang/rust/issues/48409
|
||||
RUN echo "#!/bin/sh" > rustc_wrapper.sh && \
|
||||
echo "/liana/rust-1.65.0-x86_64-unknown-linux-gnu/rustc/bin/rustc \"\$@\" -L /liana/rust-1.65.0-x86_64-pc-windows-gnu/rust-std-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/ -L /liana/rust-1.65.0-x86_64-unknown-linux-gnu/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/" >> rustc_wrapper.sh && \
|
||||
chmod +x rustc_wrapper.sh && \
|
||||
cat rustc_wrapper.sh && \
|
||||
./rustc_wrapper.sh -vV
|
||||
ENV RUSTC="/liana/rustc_wrapper.sh"
|
||||
|
||||
CMD ["./docker/build.sh"]
|
||||
13
contrib/docker/build.sh
Executable file
13
contrib/docker/build.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# =================================================================
|
||||
# The script ran within the Docker container to build the Liana GUI.
|
||||
# =================================================================
|
||||
|
||||
|
||||
# Build the GUI for Windows. The Windows Portable Execution (PE) format contains some timestamps.
|
||||
# Instruct ld to set them to 0.
|
||||
RUSTFLAGS="-Clink-arg=-Wl,--no-insert-timestamp" /liana/rust-1.65.0-x86_64-unknown-linux-gnu/cargo/bin/cargo rustc --release --target x86_64-pc-windows-gnu
|
||||
|
||||
# Avoid having to get root on the host to remove the target dir.
|
||||
chmod -R a+rw target/
|
||||
17
contrib/docker/cargo_config.toml
Normal file
17
contrib/docker/cargo_config.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[source.vendored_sources]
|
||||
directory = "vendor"
|
||||
|
||||
[source.crates-io]
|
||||
replace-with = "vendored_sources"
|
||||
|
||||
[source."https://github.com/darosior/rust-miniscript"]
|
||||
git = "https://github.com/darosior/rust-miniscript"
|
||||
branch = "multipath_descriptors_on_8.0"
|
||||
replace-with = "vendored_sources"
|
||||
|
||||
[source."https://github.com/revault/liana"]
|
||||
git = "https://github.com/revault/liana"
|
||||
branch = "master"
|
||||
replace-with = "vendored_sources"
|
||||
|
||||
# TODO: strip debug symbols as is done in Guix to reduce binary size.
|
||||
15
contrib/docker/docker-build.sh
Executable file
15
contrib/docker/docker-build.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -ex
|
||||
|
||||
TARGET_DIR="$PWD/deter_build_target"
|
||||
|
||||
docker build . -t liana_cross_compile -f contrib/docker/Dockerfile
|
||||
docker run --rm -ti \
|
||||
-v "$TARGET_DIR":/liana/target \
|
||||
-v "$PWD/contrib/docker":/liana/docker \
|
||||
-v "$PWD/gui/src":/liana/src \
|
||||
-v "$PWD/gui/static":/liana/static \
|
||||
liana_cross_compile
|
||||
|
||||
set +ex
|
||||
Loading…
x
Reference in New Issue
Block a user