Docker image nên dùng base image rõ version, cài dependency có cache tốt, không chạy bằng root nếu không cần, copy source sau dependency để tận dụng layer cache, và expose healthcheck endpoint.
Ví dụ command phổ biến:
CMD ["fastapi", "run", "app/main.py", "--port", "8000"]Trong production nên cấu hình env vars, structured logs stdout/stderr, graceful shutdown, readiness/liveness probe và giới hạn CPU/memory từ orchestrator.
The Docker image should use a pinned base image, install dependencies with good cache behavior, avoid root when possible, copy source after dependencies to reuse layers, and expose a healthcheck endpoint.
Common command example:
CMD ["fastapi", "run", "app/main.py", "--port", "8000"]Production should configure environment variables, structured logs to stdout/stderr, graceful shutdown, readiness/liveness probes and CPU/memory limits from the orchestrator.