{"id":16154348,"url":"https://github.com/ragnaroek/rust-on-raspberry-docker","last_synced_at":"2025-10-26T12:42:47.033Z","repository":{"id":52558341,"uuid":"69611859","full_name":"Ragnaroek/rust-on-raspberry-docker","owner":"Ragnaroek","description":"cross compiling rust for the raspberry pi in a docker container","archived":false,"fork":false,"pushed_at":"2025-02-15T11:03:57.000Z","size":181,"stargazers_count":80,"open_issues_count":2,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T03:06:26.468Z","etag":null,"topics":["cross-compiler","docker-image","raspberry-pi","rust-compiler"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ragnaroek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Ragnaroek"}},"created_at":"2016-09-29T22:08:01.000Z","updated_at":"2025-03-08T09:08:32.000Z","dependencies_parsed_at":"2023-12-09T08:32:09.923Z","dependency_job_id":"d09e16cd-6bd3-4bd1-86f5-9fa30a3547a2","html_url":"https://github.com/Ragnaroek/rust-on-raspberry-docker","commit_stats":{"total_commits":105,"total_committers":9,"mean_commits":"11.666666666666666","dds":"0.21904761904761905","last_synced_commit":"8eaa3bd7c7de08c642d91fd9a240baffce37f55f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragnaroek%2Frust-on-raspberry-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragnaroek%2Frust-on-raspberry-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragnaroek%2Frust-on-raspberry-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragnaroek%2Frust-on-raspberry-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ragnaroek","download_url":"https://codeload.github.com/Ragnaroek/rust-on-raspberry-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430872,"owners_count":20937874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-compiler","docker-image","raspberry-pi","rust-compiler"],"created_at":"2024-10-10T01:16:43.122Z","updated_at":"2025-10-26T12:42:47.028Z","avatar_url":"https://github.com/Ragnaroek.png","language":"Shell","funding_links":["https://github.com/sponsors/Ragnaroek","https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026link=https://github.com/sponsors/Ragnaroek","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=A24SWQT3P5DY2\u0026source=url"],"categories":[],"sub_categories":[],"readme":"[![DockerHub](https://img.shields.io/badge/DockerHub-1.87.0-blue.svg)](https://hub.docker.com/r/ragnaroek/rust-raspberry/)\n\n[![Github Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026link=https://github.com/sponsors/Ragnaroek)](https://github.com/sponsors/Ragnaroek)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=A24SWQT3P5DY2\u0026source=url)\n\n# Updates\n\nBeginning with Rust version `1.78.0` the docker images will be based on `Debian bookworm`. Please report any issues you have\nwith this update in the issue section of this repo.\n\n# Cross compiling with `Docker`\nThe native process, as described in https://github.com/Ogeon/rust-on-raspberry-pi, for cross-compiling for the Raspberry Pi sets some environment variables and writes to config files on your host machine. Thus it can be difficult to remember these changes when you want to remove or upgrade the cross compiler or even repeat that process for different versions of rust on the same machine.\n\nTo make cross-compiling Rust code for the Raspberry easier you can use the `Docker` image as build from the code in this repository for building your rust code but.\n\nBasically the steps for cross compiling your project with the help of docker look like:\n\n1. Pulling the `Docker image` from the dockerhub\n2. Running a `Docker container` from that `Docker image` which takes your `rust` project (and it's platform dependencies) and then cross compiles it\n\nYou can optionally build the docker image yourself. This may be necessary if depend on stuff\nthat is not in the image provided on the dockerhub. See section \"Building your own Docker image\" for\na detailed instruction on how to build the image yourself.\n\n## Cross compiling your project with the image from the dockerhub\n\nYou need to pull the image first from the dockerhub (assuming you have docker installed):\n```\ndocker pull ragnaroek/rust-raspberry:\u003cversion\u003e\n```\nwhere `\u003cversion\u003e` is the Rust compiler version. The docker images are provided starting from\nversion 1.12.0.\n\nIf you successfully pulled the `Docker image` containing the cross compiler, you can cross compile your project:\n```\n$ docker run \\\n    --volume \u003cpath to your rust project directory\u003e:/home/cross/project \\\n    --volume \u003cpath to directory containing the platform dependencies\u003e:/home/cross/deb-deps \\ # optional, see section \"Platform dependencies\"\n    --volume \u003cpath to local cargo registry, e.g. ~/.cargo/registry\u003e:/home/cross/.cargo/registry \\ # optional, using cached registry avoids updating on every build\n    ragnaroek/rust-raspberry:\u003cversion\u003e\n    \u003ccargo command\u003e # e.g. \"build --release\"\n```\n\nThe compiled project can then be found in your `target` directory.\n\n### Platform dependencies (optional)\n\n*NOTE*: Only Raspbian `.deb` files are supported currently (but we appreciate patches for other formats)\n\nLet's say your project uses some crate that depends on having openssl\ninstalled on the system. In this case you have download the corresponding Raspbian `.deb` packages\ninto a folder on your host system and then mount this directory into your `docker` container (See section \"Cross compiling your project ...\").\n\nGet these packages either from the raspberry, or download them online.\n\n#### Using apt-get to fetch packages\nFrom a debian-based system, you may use apt-get in order to fetch packages directly from the raspbian archives. A script is provided for these \npurposes in the `apt/` folder.\n\nHere is how you would download libssl1.0 and all of its dependencies. \n```\n$ cd apt/\n# Install the raspbian keys into your local apt keychain\n$ sudo ./install-keys.sh\n$ ./download.sh libssl1.0\n```\n\nYou can also download a single deb file without recursing:\n```\napt-get -c ./apt.conf download libssl1.0\n```\n\nIf ran multiple times, only missing packages will be downloaded.\n\n\n#### Adding files manually\n\nIf you do `apt-cache show libssl1.0` on the raspberry, you'll see this in the\noutput:\n\n    Filename:    pool/main/o/openssl/libssl1.0.0_1.0.1e-2+rvt+deb7u17_armhf.deb\n\nYou should be able to find a match for that under ftp.debian.org/debian/pool, so\nthe resulting URL in this case is\n\n    http://ftp.debian.org/debian/pool/main/o/openssl/libssl-dev_1.0.1e-2+deb7u17_armhf.deb\n\nIf it's not there, see if it is still on the raspberry under\n`/var/cache/apt/archive`.\n\nIf you still can't find it, try searching for the filename online.\n\n### Additional build setup script\n\nIn order to setup the environment or do other additional processing you can define a script\n`post-install.sh` in your folder with dependencies. This script will be `source`-d in the shell used\nto do the build, so any environment variables you export will be available to the `cargo` process.\n\nThis script will take two arguments:\n\n    - the first argument is SYSROOT, the folder where all the cross compile headers and libraries\n      are present\n    - the second argument is your dependency folder, you can process any non debian dependencies you\n      may have pre-downloaded there\n\n### Cross compiling C dependencies\n\nYour project may directly or indirectly depend on C libraries. The\n[cc](https://github.com/alexcrichton/cc-rs/) crate is a common approach used in the ecosystem to\ncompile C libraries. Please see its documentation, and possibly implementation, for how to set the\nright environment variables.\n\nAlso note that `cargo` and `rustc` will compile code for two environments:\n\n    - the build scripts are compiled in the context of the host environment (x86\\_64)\n    - your code is compiled for armv7 (a 32 bit environment)\n\nWhen changing the environment variables you must ensure that you keep both environments working.\n\n\n## Building your own Docker image\n```\n$ git clone https://github.com/Ragnaroek/rust-on-raspberry-docker\n$ cd rust-on-raspberry-pi/docker\n$ docker build \\\n    --build-arg PI_TOOLS_GIT_REF=\u003cbranch/tag/commit\u003e \\ # defaults to \"master\"\n    --build-arg RUST_VERSION=\u003crustup version stable/beta/nightly\u003e \\ # defaults to \"stable\"\n    --tag \u003ctag for your docker image\u003e \\ # e.g. \"rust-nightly-pi-cross\"\n    .\n```\n\nBy setting different tags for your `Docker image` and `RUST_VERSION` you could easily build images for different version of rust and use them as need.\n\nCross-compiling with your own build image works exactly as with the one pulled from the dockerhub.\nJust replace `ragnaroek/rust-raspberry:\u003cversion\u003e` with your own image name.\n\n## Credits and History\n\nThe initial docker image was written by [schnupperboy](https://github.com/schnupperboy) and maintained by [Ogeon](https://github.com/Ogeon/). This repository contains a copy of the docker part that originally\nlived in this repository: https://github.com/Ogeon/rust-on-raspberry-pi\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragnaroek%2Frust-on-raspberry-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fragnaroek%2Frust-on-raspberry-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragnaroek%2Frust-on-raspberry-docker/lists"}