FROM rust:alpine AS builder RUN apk add --no-cache openssl-dev musl-dev RUN rustup target add x86_64-unknown-linux-musl WORKDIR /srv # Build dependencies and cache them COPY Cargo.* ./ # Build final app COPY ./src ./src RUN RUSTFLAGS=-Ctarget-feature=-crt-static \ cargo build \ --release \ --target=x86_64-unknown-linux-musl RUN objcopy \ --compress-debug-sections \ target/x86_64-unknown-linux-musl/release/tricot \ target/x86_64-unknown-linux-musl/release/tricot.compressed FROM alpine RUN apk add -U --no-cache ca-certificates libgcc COPY --from=builder \ /srv/target/x86_64-unknown-linux-musl/release/tricot.compressed \ /usr/local/bin/tricot CMD ["/usr/local/bin/tricot"]