Dockerfile 778 B

12345678910111213141516171819202122232425262728
  1. FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as chef
  2. WORKDIR /app
  3. FROM chef as planner
  4. COPY . .
  5. RUN cargo chef prepare --recipe-path recipe.json
  6. FROM chef as builder
  7. COPY --from=planner /app/recipe.json recipe.json
  8. # Build dependencies
  9. RUN cargo chef cook --release --recipe-path recipe.json
  10. COPY . .
  11. ENV SQLX_OFFLINE true
  12. # Build our project
  13. RUN cargo build --release --bin backend
  14. FROM debian:bullseye-slim AS runtime
  15. WORKDIR /app
  16. RUN apt-get update -y \
  17. && apt-get install -y --no-install-recommends openssl \
  18. # Clean up
  19. && apt-get autoremove -y \
  20. && apt-get clean -y \
  21. && rm -rf /var/lib/apt/lists/*
  22. COPY --from=builder /app/target/release/backend backend
  23. COPY configuration configuration
  24. ENV APP_ENVIRONMENT production
  25. ENTRYPOINT ["./backend"]