This commit is contained in:
parent
f73149ed75
commit
b76275230e
4 changed files with 96 additions and 2 deletions
8
.forgejo/workflows/test.yml
Normal file
8
.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- uses: https://git.kemitix.net/kemitix/rust@main
|
||||||
|
with:
|
||||||
|
args: test
|
32
Dockerfile
Normal file
32
Dockerfile
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
FROM docker.io/rust:1.78.0-slim-bookworm
|
||||||
|
|
||||||
|
# nodejs - runtime used by forgejo/github actions
|
||||||
|
# clang-16 & mold - faster linkers for rust
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
--no-install-recommends \
|
||||||
|
nodejs=18.19.0+dfsg-618.19.0+dfsg-6deb12u1deb12u1 \
|
||||||
|
clang-16=1:16.0.6-15~deb12u1 \
|
||||||
|
mold=1.10.1+dfsg-1 && \
|
||||||
|
rm -r /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN curl -L https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz -o cargo-binstall.tgz && \
|
||||||
|
tar -xzf cargo-binstall.tgz && \
|
||||||
|
rm cargo-binstall.tgz
|
||||||
|
|
||||||
|
# verify that the binaries are installed
|
||||||
|
RUN ls -l /usr/local/cargo/bin/
|
||||||
|
RUN cargo chef --version && \
|
||||||
|
rustfmt --version && \
|
||||||
|
cargo fmt --version && \
|
||||||
|
cargo clippy --version && \
|
||||||
|
mold --version && \
|
||||||
|
clang-16 --version && \
|
||||||
|
cargo --version && \
|
||||||
|
rustc --version && \
|
||||||
|
rustup --version && \
|
||||||
|
rustup show
|
||||||
|
|
||||||
|
COPY entrypoint.sh /
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
52
README.md
52
README.md
|
@ -1,3 +1,51 @@
|
||||||
# docker-builders
|
# docker-builder-rust
|
||||||
|
|
||||||
Builder images for use by forgejo actions.
|
Docker image for building Rust projects with Cargo.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
In a Forgejo action file, e.g. `.forgejo/workflows/test.yml`:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- uses: https://git.kemitix.net/kemitix/rust@main
|
||||||
|
with:
|
||||||
|
args: test
|
||||||
|
- uses: https://git.kemitix.net/kemitix/rust@main
|
||||||
|
with:
|
||||||
|
args: build
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
- nodejs
|
||||||
|
- clang-16
|
||||||
|
- mold
|
||||||
|
- rust
|
||||||
|
- cargo
|
||||||
|
- cargo-binstall
|
||||||
|
|
||||||
|
## Linking
|
||||||
|
|
||||||
|
To take advantage of the clang and mold packages, add the following to the `.cargo/config.toml` file in your project.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[target.x86_64-unknown-linux-gnu]
|
||||||
|
linker = "/usr/bin/clang-16"
|
||||||
|
rustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Binary size
|
||||||
|
|
||||||
|
To reduce the size of the debug binary, add the following to the `.cargo/config.toml` file in you project.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[profile.dev]
|
||||||
|
debug = 0
|
||||||
|
strip = "debuginfo"
|
||||||
|
```
|
||||||
|
|
6
entrypoint.sh
Normal file
6
entrypoint.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo cargo $*
|
||||||
|
ls -l
|
Loading…
Reference in a new issue