build: Switch to a static build to mitigate incompatible packages
This commit is contained in:
25
Dockerfile
25
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"]
|
||||
|
||||
Reference in New Issue
Block a user