diff --git a/Dockerfile b/Dockerfile index 0fb7108..743d0b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,28 @@ -FROM rust:1 as build +FROM rust:slim AS build +ENV TARGET x86_64-unknown-linux-musl + +RUN apt-get update && apt-get install -y musl-tools +RUN rustup target add "$TARGET" + RUN cargo install cargo-build-deps RUN cargo new --bin simply-shorten WORKDIR /simply-shorten +RUN rustup target add x86_64-unknown-linux-musl + COPY ./actix/Cargo.toml . COPY ./actix/Cargo.lock . -RUN cargo build-deps --release +RUN cargo build-deps --release --target=x86_64-unknown-linux-musl COPY ./actix/src ./src -RUN cargo build --release +RUN cargo build --release --locked --target "$TARGET" -FROM frolvlad/alpine-glibc:latest +FROM scratch -RUN apk add sqlite-libs +COPY --from=build /simply-shorten/target/x86_64-unknown-linux-musl/release/simply-shorten /simply-shorten +COPY ./actix/resources /resources -WORKDIR /opt - -COPY --from=build /simply-shorten/target/release/simply-shorten /opt/simply-shorten -COPY ./actix/resources /opt/resources - -CMD ["./simply-shorten"] +CMD ["/simply-shorten"] diff --git a/actix/Cargo.lock b/actix/Cargo.lock index 5a776b3..f4698b6 100644 --- a/actix/Cargo.lock +++ b/actix/Cargo.lock @@ -858,6 +858,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ + "cc", "pkg-config", "vcpkg", ] diff --git a/actix/Cargo.toml b/actix/Cargo.toml index 726a842..a84a8e7 100644 --- a/actix/Cargo.toml +++ b/actix/Cargo.toml @@ -26,7 +26,7 @@ categories = ["web-programming"] [dependencies] actix-web = "4.5.1" actix-files = "0.6.5" -rusqlite = "0.30.0" +rusqlite = { version = "0.30.0", features = ["bundled"] } regex = "1.10.3" rand = "0.8.5" actix-session = { version = "0.9.0", features = ["cookie-session"] }