FROM rust WORKDIR /app # copying just cargo config and making a stub main # this means docker can cache building deps # and just build the main program in watch mode # much quicker and nicer on my cpu, network, and ram lol COPY ./Cargo.toml ./Cargo.toml COPY ./Cargo.lock ./Cargo.lock RUN mkdir ./src && echo 'fn main() { println!("Using cache build!!"); loop { println!("DOCKERFILE failed..."); } }' > ./src/main.rs RUN cargo build --locked RUN rm -f ./target/debug/index COPY ./src ./src COPY ./.sqlx ./.sqlx RUN cargo build --locked RUN cp ./target/debug/index ./index CMD ["/app/index"]