Improve dockerfile

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-12-11 22:05:50 +05:30
parent 99cd30aa7e
commit ec38c59631
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
4 changed files with 6 additions and 59 deletions

42
Cargo.lock generated
View file

@ -53,7 +53,6 @@ dependencies = [
"sha1", "sha1",
"smallvec", "smallvec",
"tracing", "tracing",
"zstd",
] ]
[[package]] [[package]]
@ -320,9 +319,6 @@ name = "cc"
version = "1.0.76" version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
dependencies = [
"jobserver",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -810,15 +806,6 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
[[package]]
name = "jobserver"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.60" version = "0.3.60"
@ -1955,32 +1942,3 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
dependencies = [ dependencies = [
"winapi", "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",
]

View file

@ -3,16 +3,8 @@ name = "paste-frontend"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[profile.release]
opt-level = 3
lto = true
[[bin]]
name="paste-frontend"
path = "src/main.rs"
[dependencies] [dependencies]
actix-web = "4" actix-web = { version = "4", default-features = false, features = ["macros", "compress-brotli", "compress-gzip", "cookies"]}
tera = "1.17.1" tera = "1.17.1"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] } reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }

View file

@ -1,18 +1,14 @@
FROM rust:alpine as builder FROM rust:bullseye as builder
RUN mkdir /app RUN mkdir /app
WORKDIR /app WORKDIR /app
RUN apk update && apk add openssl-dev musl-dev
COPY Cargo.toml /app COPY Cargo.toml /app
COPY Cargo.lock /app COPY Cargo.lock /app
RUN cargo update
COPY src /app/src COPY src /app/src
COPY templates /app/templates 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 / COPY --from=builder /app/target/release/paste-frontend /
CMD ["./paste-frontend"] CMD ["/paste-frontend"]

View file

@ -68,6 +68,7 @@ async fn main() -> std::io::Result<()> {
} }
}; };
let data = Data::new(Template { paste: tera }); let data = Data::new(Template { paste: tera });
println!("Paste Server is launched on 0.0.0.0:8080");
HttpServer::new(move || { HttpServer::new(move || {
App::new() App::new()
.app_data(Data::clone(&data)) .app_data(Data::clone(&data))