From 1f6b2e45084b7172e484195519a3c2e7ede548af Mon Sep 17 00:00:00 2001 From: dal Date: Tue, 18 Mar 2025 22:41:29 -0600 Subject: [PATCH] docker optimizations --- api/.dockerignore | 41 +++++++++++++++++++++++++++++++++++++++++ api/Dockerfile | 7 ++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 api/.dockerignore diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 000000000..40c2ac5ae --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1,41 @@ +# Git +.git +.gitignore + +# Rust +target/ +**/*.rs.bk +Cargo.lock + +# IDE +.idea/ +.vscode/ +*.swp +*.swo + +# Debug files +*.pdb +*.dSYM/ + +# Test files +tests/ +*.test +*.spec + +# Documentation +docs/ +*.md +!README.md + +# Development configs +.env +.env.* +!.env.example + +# Docker +Dockerfile +.dockerignore + +# Misc +*.log +.DS_Store \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile index be721e3b0..dc2ea164e 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -9,7 +9,8 @@ FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json RUN cargo chef cook --release --recipe-path recipe.json COPY . . -RUN cargo build --release --bin bi_api +# Add optimization flags for maximum performance +RUN RUSTFLAGS="-C target-cpu=native -C opt-level=3" cargo build --release --bin bi_api FROM debian:bookworm-slim AS runtime WORKDIR /app @@ -30,6 +31,10 @@ COPY cert.pem* /usr/local/share/ca-certificates/cert.crt COPY cert.pem* /root/.postgresql/root.crt RUN update-ca-certificates +# Set production environment variables +ENV RUST_LOG=warn +ENV RUST_BACKTRACE=0 + COPY --from=builder /app/target/release/bi_api . EXPOSE 3001 ENTRYPOINT ["./bi_api"]