Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devraymondsh/ubuntu-rust
A Rust docker image built on top of Ubuntu Linux.
https://github.com/devraymondsh/ubuntu-rust
Last synced: about 1 month ago
JSON representation
A Rust docker image built on top of Ubuntu Linux.
- Host: GitHub
- URL: https://github.com/devraymondsh/ubuntu-rust
- Owner: devraymondsh
- License: mit
- Created: 2022-11-07T15:41:40.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-29T08:31:09.000Z (about 2 months ago)
- Last Synced: 2024-11-29T09:31:08.438Z (about 2 months ago)
- Language: Shell
- Size: 62.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#### A Rust docker image built on top of Ubuntu Linux.
## Supported tags:
- 24.04, 24.04-1.83, noble-1.83, noble-latest, noble, 24.04-latest, latest-1.83, 1.83, latest
- 23.04, 23.04-1.83, lunar-1.83, lunar-latest, lunar
- 22.04, 22.04-1.83, jammy-1.83, jammy-latest, jammy
- 20.04, 20.04-1.83, focal-1.83, focal-latest, focal## How to use this image
### Start a Rust instance running your app
The most straightforward way to use this image is to use a Rust container as both the build and runtime environment. In your Dockerfile, writing something along the lines of the following will compile and run your project:
```Dockerfile
FROM devraymondsh/ubuntu-rust:latestWORKDIR /usr/src/myapp
COPY . .RUN cargo install --path .
CMD ["myapp"]
```Then, build and run the Docker image:
`$ docker build -t my-rust-app .`
`$ docker run -it --rm --name my-running-app my-rust-app`This creates an image that has all of the rust tooling for the image. If you just want the compiled application which has a smaller size:
```Dockerfile
FROM devraymondsh/ubuntu-rust:latest as builder
WORKDIR /usr/src/myapp
COPY . .
RUN cargo install --path .FROM debian:buster-slim
RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/myapp /usr/local/bin/myapp
CMD ["myapp"]
```Note: Some shared libraries may need to be installed as shown in the installation of the extra-runtime-dependencies line above.
## Compile your app inside the Docker container
There may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the Docker instance, you can write something like:
`$ docker run --rm --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp -w /usr/src/myapp devraymondsh/ubuntu-rust:latest cargo build --release`
This will add your current directory, as a volume, to the container, set the working directory to the volume, and run the command cargo build --release. This tells Cargo, Rust's build system, to compile the crate in myapp and output the executable to target/release/myapp.## License
The image is licensed under the MIT license. Visit [LICENSE](https://github.com/devraymondsh/ubuntu-rust/blob/main/LICENSE) for more information.