From ec38c5963159744d4495497847e9f6a678204fe5 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 11 Dec 2022 22:05:50 +0530 Subject: [PATCH] Improve dockerfile Signed-off-by: baalajimaestro --- Cargo.lock | 42 ------------------------------------------ Cargo.toml | 10 +--------- Dockerfile | 12 ++++-------- src/main.rs | 1 + 4 files changed, 6 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f67159..f27b0e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,7 +53,6 @@ dependencies = [ "sha1", "smallvec", "tracing", - "zstd", ] [[package]] @@ -320,9 +319,6 @@ name = "cc" version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -810,15 +806,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" -[[package]] -name = "jobserver" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.60" @@ -1955,32 +1942,3 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.1+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" -dependencies = [ - "cc", - "libc", -] diff --git a/Cargo.toml b/Cargo.toml index c513f79..59b9b4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,16 +3,8 @@ name = "paste-frontend" version = "0.1.0" edition = "2021" -[profile.release] -opt-level = 3 -lto = true - -[[bin]] -name="paste-frontend" -path = "src/main.rs" - [dependencies] -actix-web = "4" +actix-web = { version = "4", default-features = false, features = ["macros", "compress-brotli", "compress-gzip", "cookies"]} tera = "1.17.1" serde = { version = "1.0", features = ["derive"] } reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] } diff --git a/Dockerfile b/Dockerfile index f78a114..feed168 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,14 @@ -FROM rust:alpine as builder +FROM rust:bullseye as builder RUN mkdir /app WORKDIR /app -RUN apk update && apk add openssl-dev musl-dev - COPY Cargo.toml /app COPY Cargo.lock /app -RUN cargo update - COPY src /app/src COPY templates /app/templates -RUN cargo build --release --target x86_64-unknown-linux-musl +RUN cargo build --release -FROM scratch +FROM gcr.io/distroless/cc:nonroot COPY --from=builder /app/target/release/paste-frontend / -CMD ["./paste-frontend"] +CMD ["/paste-frontend"] diff --git a/src/main.rs b/src/main.rs index 3d401fc..282c99c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,7 @@ async fn main() -> std::io::Result<()> { } }; let data = Data::new(Template { paste: tera }); + println!("Paste Server is launched on 0.0.0.0:8080"); HttpServer::new(move || { App::new() .app_data(Data::clone(&data))