From 8fbb8eda2d828739b2766b584658ec8851252d57 Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 14 Apr 2026 18:16:15 +0300 Subject: [PATCH] =?UTF-8?q?CodeBench:=20esik=C3=A4=C3=A4nn=C3=A4=20Rust-ri?= =?UTF-8?q?ippuvuudet=20Docker-imageen=20=E2=80=94=2035x=20nopeampi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dummy-projekti samalla Cargo.toml:llä: cargo check + cargo build --tests imageen. Runtime kääntyy vain itse projekti (~2.5s vs ~90s). --- kipina-codebench/Dockerfile.cargo-test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/kipina-codebench/Dockerfile.cargo-test b/kipina-codebench/Dockerfile.cargo-test index 741b589..0a10c9c 100644 --- a/kipina-codebench/Dockerfile.cargo-test +++ b/kipina-codebench/Dockerfile.cargo-test @@ -1,4 +1,28 @@ FROM rust:1.87-slim RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/* WORKDIR /work + +# Esikäännä riippuvuudet dummy-projektilla — nämä cachetaan Docker-layeriin +RUN cargo init --name bench-precompile . && \ + cat > Cargo.toml <<'TOML' +[package] +name = "bench-precompile" +version = "0.1.0" +edition = "2024" + +[dependencies] +axum = "0.8" +tokio = { version = "1", features = ["full"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio"] } +tower-http = { version = "0.6", features = ["cors"] } +chrono = { version = "0.4", features = ["serde"] } + +[dev-dependencies] +reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } +tokio = { version = "1", features = ["full", "test-util"] } +TOML +RUN cargo check 2>&1 && cargo build --tests 2>&1 && rm -rf src target/debug/deps/bench_precompile* target/debug/bench-precompile* + ENTRYPOINT ["sh", "-c", "cp -r /src/* . && cargo test 2>&1"]