From d61c0fc5a5cfadbb200be776b6183ec2c92a762d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 26 May 2025 13:12:08 -0400 Subject: [PATCH] Update Docker container to use FastAPI CLI directly Remove package installation step and use FastAPI CLI with PYTHONPATH for simpler container execution. Disable reload in main.py and include static/templates as package data for proper distribution. --- Dockerfile | 7 +++---- kjvstudy_org/main.py | 2 +- pyproject.toml | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd81e50..26808ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ + PYTHONPATH="/app" \ PATH="/app/.venv/bin:$PATH" WORKDIR /app @@ -33,7 +34,5 @@ COPY --from=builder /app/.venv /app/.venv # Copy application code COPY . . -# Install the project itself -RUN uv pip install --no-deps . - -CMD ["kjvstudy-org"] +# Run the application using FastAPI CLI +CMD ["fastapi", "run", "kjvstudy_org.server:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/kjvstudy_org/main.py b/kjvstudy_org/main.py index 78836ca..79daddf 100644 --- a/kjvstudy_org/main.py +++ b/kjvstudy_org/main.py @@ -8,7 +8,7 @@ def main(): "kjvstudy_org.server:app", host="0.0.0.0", port=8000, - reload=True, + reload=False, log_level="info" ) diff --git a/pyproject.toml b/pyproject.toml index 7c010b1..9ba0e96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] where = ["."] include = ["kjvstudy_org*"] -exclude = ["static", "templates"] + +[tool.setuptools.package-data] +kjvstudy_org = ["static/*", "templates/*"] [tool.uv] package = true