Skip to content

Instantly share code, notes, and snippets.

@jmrepetti
Last active April 1, 2023 17:27
Show Gist options
  • Save jmrepetti/7c49a9d2bc4ab534a6fbff7bc96a6381 to your computer and use it in GitHub Desktop.
Save jmrepetti/7c49a9d2bc4ab534a6fbff7bc96a6381 to your computer and use it in GitHub Desktop.
Generate Rust project using Podman
#!/bin/bash
podman run \
-i `#Keep STDIN open even if not attached`\
-t `#Allocate a pseudo-TTY for container`\
--rm `#Remove container (and pod if created) after exit`\
-e CARGO_HOME=./cargo `#persist registry within project`\
-v ./:/new_rust_project `#Bind mount a volume into the container`\
--security-opt label=disable `#allow me to write on mounted volume`\
-w /new_rust_project `#Working directory inside the container`\
--name rust_cmd `#Assign a name to the container`\
rust `#IMAGE`\
$@
@jmrepetti
Copy link
Author

jmrepetti commented Apr 1, 2023

Save snippet to cargo.sh file and give +x permissions.

Change 'new_rust_project' with your preferred name.

USAGE:

./cargo.sh cargo init  #initialize project
./cargo.sh cargo run  

You can mount your existing cargo registry with:

-v /home/user/.cargo:/cargo_home 
-e CARGO_HOME=/cargo_home 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment