Skip to content

Commit

Permalink
Add cross-compilation dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lukipuki committed Mar 29, 2024
1 parent dcc9b2b commit 95253a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/conf
/target
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
FROM docker.io/python:3.11-slim-bookworm
FROM ubuntu:noble

RUN apt update && apt install -y cargo libudev-dev pkg-config
COPY conf/sources.list /etc/apt/sources.list
RUN apt update
RUN dpkg --add-architecture armhf

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt install -y gcc-arm-linux-gnueabihf rustup build-essential
RUN apt install -y pkg-config python3 python3-pip python3-venv protobuf-compiler
RUN apt install -y libudev-dev:armhf

RUN rustup default stable && rustup target add armv7-unknown-linux-gnueabihf

WORKDIR /app
COPY . .
RUN pip install maturin && maturin develop

ENV PKG_CONFIG_ALLOW_CROSS=1
ENV PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
ENV PYO3_CROSS_PYTHON_VERSION=3.12
RUN cargo build --release --target armv7-unknown-linux-gnueabihf

0 comments on commit 95253a9

Please sign in to comment.