-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.cross
More file actions
42 lines (35 loc) · 1.46 KB
/
Dockerfile.cross
File metadata and controls
42 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Dockerfile for cross-compiling HyperCalibrate for Raspberry Pi
# Supports both aarch64 (64-bit) and armv7 (32-bit) targets
# Pin to Rust 1.85 on Bookworm - needed for home crate edition2024
# rust:latest requires glibc 2.39+ which is newer than Raspberry Pi OS (glibc 2.36)
FROM rust:1.85-bookworm
# Install cross-compilation tools, cmake, and libclang for bindgen
# g++-aarch64-linux-gnu is needed for turbojpeg-sys (libjpeg-turbo)
RUN apt-get update && apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross \
pkg-config \
cmake \
nasm \
clang \
libclang-dev \
&& rm -rf /var/lib/apt/lists/*
# Add Rust targets for Raspberry Pi
RUN rustup target add aarch64-unknown-linux-gnu \
&& rustup target add armv7-unknown-linux-gnueabihf
# Create cargo config for cross-compilation
RUN mkdir -p /root/.cargo && \
echo '[target.aarch64-unknown-linux-gnu]\n\
linker = "aarch64-linux-gnu-gcc"\n\
\n\
[target.armv7-unknown-linux-gnueabihf]\n\
linker = "arm-linux-gnueabihf-gcc"' > /root/.cargo/config.toml
WORKDIR /app
# Default to 64-bit build (Raspberry Pi 5 is 64-bit)
ENV TARGET=aarch64-unknown-linux-gnu
# Build command with target CPU optimization for RPi5 (Cortex-A76)
CMD ["sh", "-c", "RUSTFLAGS='-C target-cpu=cortex-a76' cargo build --release --target $TARGET && cp target/$TARGET/release/hypercalibrate /output/"]