{"id":16868113,"url":"https://github.com/fornwall/rust-static-builder","last_synced_at":"2025-10-16T10:44:44.517Z","repository":{"id":33614832,"uuid":"159952208","full_name":"fornwall/rust-static-builder","owner":"fornwall","description":"Docker image to build statically linked Linux executables from Rust projects.","archived":false,"fork":false,"pushed_at":"2024-09-04T10:29:26.000Z","size":434,"stargazers_count":49,"open_issues_count":0,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-18T09:12:56.609Z","etag":null,"topics":["docker","musl","rust","statically-linking"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fornwall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2018-12-01T14:23:43.000Z","updated_at":"2025-02-23T08:56:36.000Z","dependencies_parsed_at":"2024-10-28T12:29:53.366Z","dependency_job_id":null,"html_url":"https://github.com/fornwall/rust-static-builder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fornwall%2Frust-static-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fornwall%2Frust-static-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fornwall%2Frust-static-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fornwall%2Frust-static-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fornwall","download_url":"https://codeload.github.com/fornwall/rust-static-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244924945,"owners_count":20532872,"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":["docker","musl","rust","statically-linking"],"created_at":"2024-10-13T14:57:06.819Z","updated_at":"2025-10-16T10:44:39.463Z","avatar_url":"https://github.com/fornwall.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status](https://github.com/fornwall/rust-static-builder/workflows/Build/badge.svg)](https://github.com/fornwall/rust-static-builder/actions?query=branch%3Amaster)\n[![Docker Hub](https://img.shields.io/docker/v/fredrikfornwall/rust-static-builder.svg?label=docker)](https://hub.docker.com/r/fredrikfornwall/rust-static-builder)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\n# Rust static binary builder\nDocker image for building statically linked x86_64 Linux binaries from Rust projects.\n\n## Building\nFrom inside your project directoring containing a `Cargo.toml` file:\n\n```sh\n# Stable release channel:\ndocker run -v \"$PWD\":/build fredrikfornwall/rust-static-builder:1.80.1\n\n# Nightly release channel:\ndocker run -v \"$PWD\":/build fredrikfornwall/rust-static-builder-nightly:2024-09-04\n```\n\nA statically linked binary will be created under `target/x86_64-unknown-linux-musl/release/`.\n\n## Speeding up builds by sharing registry and git folders\nTo speed up builds the cargo registry and git folders can be mounted:\n\n```sh\ndocker run \\\n       -v \"$PWD\":/build \\\n       -v $HOME/.cargo/git:/root/.cargo/git \\\n       -v $HOME/.cargo/registry:/root/.cargo/registry \\\n       fredrikfornwall/rust-static-builder:1.80.1\n```\n\n## Testing\nOverride the entry point to run tests against the statically linked binary:\n\n```sh\ndocker run \\\n       -v \"$PWD\":/build \\\n       -v $HOME/.cargo/git:/root/.cargo/git \\\n       -v $HOME/.cargo/registry:/root/.cargo/registry \\\n       --entrypoint cargo \\\n       fredrikfornwall/rust-static-builder:1.80.1 \\\n       test --target x86_64-unknown-linux-musl\n```\n\n## Disable stripping\nBy default the built binary will be stripped. Run with `-e NOSTRIP=1`, as in\n\n```sh\ndocker run \\\n       -e NOSTRIP=1 \\\n       -v \"$PWD\":/build \\\n       fredrikfornwall/rust-static-builder:1.80.1\n```\n\nto disable stripping.\n\n## Creating a lightweight Docker image\nThe built binary can be used to create a lightweight Docker image built from scratch:\n\n```dockerfile\nFROM scratch\nCOPY target/x86_64-unknown-linux-musl/release/my-executable /\nENTRYPOINT [\"/my-executable\"]\n```\n\n## Native libraries and OpenSSL\nThe rust-static-builder image contains statically libraries for the following images in order for crates to be able to link them in:\n\n- [bzip2](https://www.sourceware.org/bzip2/)\n- [liblzma](https://tukaani.org/xz/)\n- [openssl](https://www.openssl.org/)\n- [sqlite](https://www.sqlite.org/)\n- [zlib](https://zlib.net/)\n\nNote that if the projects needs certificates for OpenSSL a [base image containing /cacert.pem](scratch-with-certificates/Dockerfile) can be used when building a Docker image:\n\n```dockerfile\nFROM fredrikfornwall/scratch-with-certificates\nCOPY target/x86_64-unknown-linux-musl/release/tls-using-executable /\nENTRYPOINT [\"/tls-using-executable\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffornwall%2Frust-static-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffornwall%2Frust-static-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffornwall%2Frust-static-builder/lists"}