Feat: docker image
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Dorian Zedler 2023-03-12 00:04:47 +01:00
parent e496324049
commit 2329b80ed8
Signed by: dozedler
GPG key ID: 989DE36109AFA354
8 changed files with 1113 additions and 8 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
target
Dockerfile
.dockerignore

4
.gitignore vendored
View file

@ -4,10 +4,6 @@
debug/ debug/
target/ target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk

14
.woodpecker.yml Normal file
View file

@ -0,0 +1,14 @@
pipeline:
build-and-publish:
image: plugins/docker
settings:
registry: git.makerlab-murnau.de
repo: git.makerlab-murnau.de/makerlab/matrix-bot
auto_tag: true
dockerfile: Dockerfile
username:
from_secret: gitea_username
password:
from_secret: gitea_password
when:
branch: main

1080
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -7,10 +7,9 @@ edition = "2021"
[dependencies] [dependencies]
png = "0.11.0" png = "0.11.0"
cairo-rs = { version = "0.17.0", features = ["png"] } cairo-rs = { version = "0.17.0", default-features = false, features = ["png"] }
axum = "0.6.10" axum = "0.6.10"
tokio = { version = "1.0", features = ["full"] } tokio = { version = "1.0", features = ["full"] }
base64 = "0.21.0"
rand = "0.8.5" rand = "0.8.5"
serde = { version = "1.0.152", features = ["derive"] } serde = { version = "1.0.152", features = ["derive"] }
rust-embed = "6.6.0" rust-embed = "6.6.0"

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM rust:1.68-bookworm as build
WORKDIR /build
COPY . .
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN echo $(rustup show | head -n 1 | awk '{print $NF}') > /platform
RUN cargo build --release --target $(cat /platform) --bin logo-generator
RUN mv target/$(cat /platform)/release/logo-generator logo-generator
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y libcairo2-dev && rm -rf /var/lib/apt/lists/*
COPY --from=build /build/logo-generator /logo-generator
EXPOSE 3000
CMD ["/logo-generator"]

View file

@ -18,7 +18,7 @@ async fn main() {
.with_state(state); .with_state(state);
// run it // run it
let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
println!("listening on {}", addr); println!("listening on {}", addr);
axum::Server::bind(&addr) axum::Server::bind(&addr)
.serve(app.into_make_service()) .serve(app.into_make_service())

View file

@ -31,7 +31,7 @@
</ul> </ul>
<ul> <ul>
<li><a href="https://makerlab-murnau.de">MakerLab Website</a></li> <li><a href="https://makerlab-murnau.de">MakerLab Website</a></li>
<li><a href="https://git.makerlab-murnau.de/Projekte/logo-generator">Source code</a></li> <li><a href="https://git.makerlab-murnau.de/MakerLab/logo-generator">Source code</a></li>
</ul> </ul>
</nav> </nav>