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"]