Maybe not relevant anymore but I bumped into the same issue today, I'm not an expert on uv/python but when running the container with:
ENTRYPOINT ["uv", "run", "--verbose", "otel_ex"]
I saw a debug message like: DEBUG Cached revision does not match expected cache info for...
as the reason to rebuild the container. I found a way to get it working without the rebuild by using --no-sync
with my uv run
command in the entrypoint
:
pyproject.toml:
[project]
name = "otel-example"
version = "0.1.0"
description = "some-project"
readme = "README.md"
requires-python = ">=3.13"
dependencies = []
[project.scripts]
otel_ex = "otel_example:main"
[build-system]
requires = ["flit_core~=3.2"]
build-backend = "flit_core.buildapi"
[tool.uv]
default-groups = []
Dockerfile:
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
RUN useradd --user-group --home-dir /app --no-create-home --shell /bin/bash pyuser
USER pyuser
COPY --chown=pyuser:pyuser . /app
WORKDIR /app
RUN uv sync --compile-bytecode --frozen
ENTRYPOINT ["uv", "run", "--no-sync", "otel_ex"]
hope this helps!
P.S. With regards to the context, I use gitlab-ci
and docker buildx
with the kubernetes driver to build the container images and upload them to goharbor. Maybe someone with more knowledge on this topic can add?