build: Switch to a static build to mitigate incompatible packages

This commit is contained in:
SinTan1729
2024-02-08 11:33:26 -06:00
parent 583700cdbf
commit caa6c58fd2
3 changed files with 16 additions and 12 deletions

View File

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