Skip to content

Instantly share code, notes, and snippets.

@sguzman
Created November 4, 2018 20:33
Show Gist options
  • Save sguzman/5c0c9dc43426086d54571be125e69cdb to your computer and use it in GitHub Desktop.
Save sguzman/5c0c9dc43426086d54571be125e69cdb to your computer and use it in GitHub Desktop.
Dockerfile for rustup with building deps first
FROM liuchong/rustup:musl AS base
RUN mkdir app
WORKDIR ./app
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN rustup target add x86_64-unknown-linux-musl
RUN rustup install nightly
RUN cargo install cargo-build-deps --verbose --color always
RUN cargo build-deps --release
ADD src src
ARG name=weighted-consumer
RUN cargo build --package $name --bin $name --verbose --jobs 2 --all-features --release --target=x86_64-unknown-linux-musl --color always
FROM scratch
COPY --from=base /root/app/target/x86_64-unknown-linux-musl/release/weighted-consumer /main
ENTRYPOINT ["/main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment