FROM rust:1-bullseye AS BUILD WORKDIR /app RUN cargo init COPY Cargo.toml . COPY Cargo.lock . # To cache dependecies RUN cargo build --release && cargo test RUN useradd -ms /bin/bash wizard RUN chown -R wizard:wizard /usr/local/cargo/ RUN chown -R wizard:wizard /app/ COPY src/ src/ RUN cargo build --release RUN cp target/release/treq /usr/local/bin && chmod +x /usr/local/bin/treq COPY tests/ tests/ USER wizard