From 99cd30aa7ed0f56640ad04d90d063829012979b8 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 11 Dec 2022 21:03:16 +0530 Subject: [PATCH] Add dockerfile Signed-off-by: baalajimaestro --- .dockerignore | 1 + Cargo.toml | 8 ++++++++ Dockerfile | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target/ diff --git a/Cargo.toml b/Cargo.toml index ff900c7..c513f79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,14 @@ 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" tera = "1.17.1" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f78a114 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM rust:alpine 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 + +FROM scratch +COPY --from=builder /app/target/release/paste-frontend / +CMD ["./paste-frontend"]