Python with UV
Basic Dockerfile
for production like run
# Base image
FROM python:3.14.2-slim-trixie
# Get UV
COPY --from=docker.io/astral/uv:latest /uv /uvx /bin/
# set work directory
WORKDIR /app
# install dependencies
## Install python as system
#ENV UV_SYSTEM_PYTHON=1 # Install UV as system package
COPY pyproject.toml uv.lock .python-version ./
RUN uv sync --frozen --no-dev --compile-bytecode
# Copy scripts to local folder
COPY . .
# Start server
CMD ["uv", "run", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "80"]Dev Dockerfile
to be used for DEV environment
# docker-compose.yml
services:
app:
build: .
container_name: app-backend
command: uv run uvicorn src.main:app --host 0.0.0.0 --port 80 --reload
ports:
- 8080:80
volumes:
- .:/app
- /app/.venv # persist container .venv