Add Dockerfile and docker-compose.yml (#8)#13
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds initial Docker support for local development and containerized runs.
- Introduces a Dockerfile using python:3.13-slim-trixie and uv for dependency management.
- Adds a minimal docker-compose.yml to build the image, set working directory, and bind-mount the project.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| Dockerfile | Builds a Python 3.13 image, installs build tools and graphviz, copies the app, installs deps with uv, and sets PATH. |
| docker-compose.yml | Defines an app service with build context, TTY, working_dir, and a host bind mount to /app. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| tty: true | ||
| working_dir: /app | ||
| volumes: | ||
| - .:/app |
There was a problem hiding this comment.
The bind mount of the project root to /app will shadow any files created at build time under /app, including the virtual environment created by uv sync in the Docker image (/app/.venv). This makes the layer from uv sync ineffective in dev containers. Consider either (a) moving the virtual environment outside /app (e.g., set ENV UV_PROJECT_ENVIRONMENT=/venv and ENV PATH="/venv/bin:$PATH" in the Dockerfile) or (b) mounting a named volume at /app/.venv in compose so it is not overridden by the bind mount.
| - .:/app | |
| - .:/app | |
| - venv:/app/.venv | |
| volumes: | |
| venv: |
| COPY . /app | ||
| WORKDIR /app | ||
|
|
||
| RUN uv sync --frozen |
There was a problem hiding this comment.
Copying the entire build context before running uv sync prevents effective layer caching; any code change invalidates dependency installation. Reorder to copy only dependency manifests first, run uv sync, then copy the rest. Example: set WORKDIR /app, COPY pyproject.toml uv.lock* /app/, RUN uv sync --frozen, then COPY . /app.
| COPY . /app | |
| WORKDIR /app | |
| RUN uv sync --frozen | |
| WORKDIR /app | |
| COPY pyproject.toml uv.lock* /app/ | |
| RUN uv sync --frozen | |
| COPY . /app |
| @@ -0,0 +1,14 @@ | |||
| FROM python:3.13-slim-trixie | |||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |||
There was a problem hiding this comment.
[nitpick] Using the floating tag latest for the uv image makes builds non-reproducible and can break unexpectedly when upstream updates. Pin to a specific version or digest, e.g., COPY --from=ghcr.io/astral-sh/uv:vX.Y.Z /uv /uvx /bin/ or use a @sha256 digest.
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| COPY --from=ghcr.io/astral-sh/uv:v0.1.23 /uv /uvx /bin/ |
| app: | ||
| build: . | ||
| tty: true | ||
| working_dir: /app |
There was a problem hiding this comment.
[nitpick] The service does not define a command, which makes behavior depend on the base image default (currently python3). For predictable developer experience, specify an explicit command (e.g., bash, uv run your_app, or a dev server entrypoint) aligned with your workflow.
| working_dir: /app | |
| working_dir: /app | |
| command: bash |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces Docker support for the project, enabling containerized development and deployment. The main changes include the addition of a
Dockerfilefor building the application image and adocker-compose.ymlfor orchestrating the container setup.Containerization setup:
Dockerfilebased onpython:3.13-slim-trixie, installs dependencies, and usesuvfor Python environment management.docker-compose.ymlto define a service for the application, specifying build context, working directory, and volume mounting for local development.