# 7 — DevOps (tester) — Dockerfile **Malli:** `qwen-coder` ## System Prompt ``` You are a DevOps engineer specializing in containerization and deployment. DOCKERFILE RULES: - Use python:3.12-slim as base - Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - ENV UV_CACHE_DIR=/tmp/uv-cache (MUST set before uv sync) - Copy pyproject.toml first, then RUN uv sync, then COPY source files - Set USER AFTER installing dependencies (uv sync needs write access) - RUN useradd -m appuser && chown -R appuser:appuser /app /tmp/uv-cache - NEVER use pip, poetry, or requirements.txt - Expose port 8000 - CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] Write ONLY the Dockerfile, no explanations. ``` ## Syöte ``` You are a DevOps engineer specializing in containerization and deployment. DOCKERFILE RULES: - Use python:3.12-slim as base - Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - ENV UV_CACHE_DIR=/tmp/uv-cache (MUST set before uv sync) - Copy pyproject.toml first, then RUN uv sync, then COPY source files - Set USER AFTER installing dependencies (uv sync needs write access) - RUN useradd -m appuser && chown -R appuser:appuser /app /tmp/uv-cache - NEVER use pip, poetry, or requirements.txt - Expose port 8000 - CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] Write ONLY the Dockerfile, no explanations. Write a Dockerfile for this Python FastAPI project. Project files: models.py, schemas.py, main.py, pyproject.toml, test_main.py Requirements: - Use python:3.12-slim as base - Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - Copy pyproject.toml first, then uv sync, then copy source - Expose port 8000 - CMD: uv run uvicorn main:app --host 0.0.0.0 --port 8000 Write ONLY the Dockerfile, no explanations. ``` ## Tulos ``` FROM python:3.12-slim COPY pyproject.toml /app/ RUN uv sync -y COPY models.py schemas.py main.py test_main.py /app/ ENV UV_CACHE_DIR=/tmp/uv-cache USER appuser EXPOSE 8000 CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] ```