# This Dockerfile is mostly for CI, see .github/workflows/tests.yml # Run with --build-arg=channel=stable OR --build-arg=channel=nightly (default) ARG rust=nightly # Using Dockerfile conditionals #### Base image for STABLE FROM rust AS cargo-base-stable ENV components="rustfmt clippy" buildflags="--tests --examples" #### Base image for NIGHTLY FROM rustlang/rust:nightly AS cargo-base-nightly ENV components="" buildflags="--tests --examples" #### Base image for MSRV FROM rust:1.60.0 AS cargo-base-msrv # Don't build tests: dev-dependencies are incompatible with MSRV. ENV components="" buildflags="" #### Common logic for base image FROM cargo-base-$rust AS cargo-build WORKDIR /root/build # Make warnings fatal ENV RUSTFLAGS="-D warnings" RUN apt-get update && \ apt-get install -y libacl1-dev && \ rm -rf /var/lib/apt/lists/* RUN if test -n "$components"; then rustup component add $components; fi # Build Cargo dependencies for cache COPY Cargo.toml ./ RUN mkdir src/ && \ echo "pub fn main() {println!(\"dummy function\")}" > src/lib.rs && \ cargo build --lib $buildflags --color=always && \ rm -rdv target/*/deps/posix_acl-* \ target/*/.fingerprint/posix-acl-* # Do the actual build COPY . . RUN cargo build --lib $buildflags --color=always