FROM rust:1.48 as builder RUN USER=root cargo new --bin disle WORKDIR ./disle COPY ./Cargo.toml ./Cargo.toml RUN cargo build --release RUN rm src/*.rs ADD . ./ RUN rm ./target/release/deps/disle* RUN cargo build --release FROM debian:buster-slim ARG APP=/usr/src/app RUN apt-get update \ && apt-get install -y ca-certificates tzdata \ && rm -rf /var/lib/apt/lists/* ENV TZ=Etc/UTC \ APP_USER=appuser RUN groupadd $APP_USER \ && useradd -g $APP_USER $APP_USER \ && mkdir -p ${APP} COPY --from=builder /disle/target/release/disle ${APP}/disle RUN chown -R $APP_USER:$APP_USER ${APP} USER $APP_USER WORKDIR ${APP} CMD ["./disle"]