Skip to content

[FEATURE] Improve backend Dockerfile for proper uv dependency management and build optimization #72

@VarshVishwakarma

Description

@VarshVishwakarma

Problem / Motivation

The current backend Dockerfile installs dependencies using:

RUN uv pip install --system -r pyproject.toml

However, pyproject.toml is not a requirements file and using it with -r is not the recommended workflow for uv. This may lead to inconsistent dependency resolution and does not fully leverage the existing uv.lock file for reproducible builds.

Additionally, the current Dockerfile can be improved for:

better Docker layer caching,
smaller rebuild times,
cleaner production practices,
and improved container reliability.
Proposed Solution

Refactor the backend Dockerfile to use a proper uv workflow such as:

RUN uv sync --frozen --no-dev

Additional improvements:

optimize dependency caching by copying dependency files before source files,
add production-friendly Python environment variables,
improve runtime execution consistency using uv run,
optionally introduce .dockerignore recommendations.

Example improvements include:

deterministic builds using uv.lock,
faster rebuilds,
cleaner container behavior in production and CI/CD environments.
Alternatives Considered
Continuing with uv pip install --system -r pyproject.toml
not aligned with recommended uv workflows,
does not fully utilize lockfile reproducibility.
Exporting requirements.txt manually
adds unnecessary maintenance overhead when uv.lock already exists.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions