fast, full-stack Python (uv & Docker)

python
docker
uv
Author

Cody

Published

November 25, 2024

Using uv and Docker to develop and deploy simple, scalable, full-stack Python applications.


In this post, we’ll look at my Dockerfile:

# dkdc Dockerfile
FROM ghcr.io/astral-sh/uv:latest AS uv
FROM python:3.12-slim
# set the environment variables
ENV PATH=/root/.local/bin:$PATH
# set the working directory
WORKDIR /app
# copy the files
COPY readme.md /app/readme.md
COPY pyproject.toml /app/pyproject.toml
COPY src /app/src
# install the Python packages
RUN --mount=type=cache,target=/root/.cache/uv \
    --mount=from=uv,source=/uv,target=./uv \
    ./uv pip install '.' --system --upgrade

I use it to develop simple, scalable, full-stack Python applications built with:

Then, deploy them with ease (and minimal build times) locally, on a Raspberry Pi, and on a cloud VM. Of course, other open source software and Python packages are used along the way (and you can use whatever you like!).

Some miscellaneous notes:

Combining this with a few justfile commands makes development and deployment very easy. The simplicity of Python and tools that cover the full stack (CLI, database, GUI) make it a great choice for rapidly prototyping scalable applications.

Back to top