FROM rust:latest as build # 1. Create a new empty shell project RUN USER=root cargo new --bin nerdcult_admin_worker WORKDIR /nerdcult_admin_worker # 2. Copy our manifests COPY ./Cargo.lock ./Cargo.lock COPY ./Cargo.toml ./Cargo.toml # 3. Build only the dependencies to cache them RUN cargo build --release RUN rm src/*.rs # 4. Now that the dependency is built, copy your source code COPY ./src ./src COPY .sqlx .sqlx # 5. Build for release. RUN rm ./target/release/deps/admin_worker* RUN SQLX_OFFLINE=true NC_AW_BACKUP_PATH=/data/backup NC_AW_HOST_PATH=/host cargo build --release FROM debian:bookworm-slim COPY --from=build /nerdcult_admin_worker/target/release/admin-worker /bin/admin-worker CMD ["/bin/admin_worker"]