Crates.io | crates-registry |
lib.rs | crates-registry |
version | 0.1.3 |
source | src |
created_at | 2023-09-11 09:04:36.880469 |
updated_at | 2023-09-23 17:38:48.906024 |
description | Crates Registry is a tool for serve crates and rustup installation in offline networks. The project is based on panamax project and cargo-http-registry and use theis code. |
homepage | https://github.com/TalRoni/crates-registry |
repository | https://github.com/TalRoni/crates-registry.git |
max_upload_size | |
id | 969401 |
size | 5,516,458 |
Crates Registry is a tool for serving and publishing crates and serving rustup installation in offline networks. (like Verdaccio as npm registry) The project partially uses code from these open source projects: panamax project and cargo-http-registry and they deserve credit accordingly.
Crates Registry can be installed with cargo:
$ cargo install crates-registry
Also available in docker (recommended for serving use):
$ docker run -d --name crates-registry -e RUST_LOG=info -v /path/to/mirror-folder:/registry -p 80:80 crates-registry:latest serve -s <server ip> --root-registry /registry
(Modify /path/to/registry port and server-IP as needed)
There are several possible uses:
Packing rust installations on the online side to serve later in the offline network. We download the rust installations in self-contained directories and pack the directory in tar file. packing example:
$ crates-registry pack --pack-file packed_file.tar --rust-versions 1.67.1,04-03-2023-nightly --platfroms x86_64-unknown-linux-gnu
Run crates-registry pack --help
for all available options.
Unpack the packed file that contains the rustup installations in the registry folder. You can load the tar file through the UI at http://server-adress/manage-installations. Follow the instructions in the page. Another option is to load the tar file using the unpack command:
$ crates-registry pack --packed-file /packed_file.tar --root-registry /path/to/registry/folder
The Crates Registry provides an HTTP server that can handle serving the crates and rustup installations fast and at scale. serving example:
$ docker run -d --name crates-registry -e RUST_LOG=info -v /path/to/mirror-folder:/registry -p 80:80 crates-registry:latest serve -s <server ip> --root-registry /registry
(Modify /path/to/registry port and server-IP as needed)
Run crates-registry serve --help
for all available options.
Once you have a server set up and running, it's time to tell your rust components to use it.
To ensure rustup knows where to look for the Rust components, we need to set some environment variables. Assuming the server is hosted at http://crates.registry/:
export RUSTUP_DIST_SERVER=http://crates.registry
export RUSTUP_UPDATE_ROOT=http://crates.registry/rustup
These need to be set whenever rustup is used, so these should be added to your .bashrc file (or equivalent).
To install rustup
you can download the rustup-init file. The rustup-init
file you want depends on your architecture. Assuming you're running desktop Linux on a 64-bit machine:
wget http://crates.registry/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x rustup-init
./rustup-init
This will let you install rustup the similarly following the steps from https://rustup.rs. This will also let you use rustup to keep your Rust installation updated in the future.
Cargo also needs to be configured to point to the mirror. This can be done by adding the following lines to ~/.cargo/config (creating the file if it doesn't exist):
[source.my-mirror]
registry = "http://crates.registry/git/index"
[source.crates-io]
replace-with = "my-mirror"
# For publish crates.
[registries]
my-registry = { index = "https://crates.registry/git/index" }
Cargo should now be pointing to the correct location to use the mirror.
Tow utilities to import new crates:
You can also publish crates using the cargo publish
command.
Licensed under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 and the Apache License (Version 2.0)