The agent package is installed by the other two apps.
I need to build a docker image that setups up the api package so I modified the cached example in the docs.
FROM python:3.11-slim-bullseye
COPY --from=ghcr.io/astral-sh/uv:0.4.9 /uv /bin/uv
# Set Working directory
WORKDIR /app
RUN addgroup --system app && adduser --system --group app
RUN chown -R app:app /app
USER app
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-workspace --no-dev
# Copy only requirements to cache them in docker layer
COPY --chown=app:app pyproject.toml uv.lock /app/
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
COPY --chown=app:app agent/ /app/agent/
COPY --chown=app:app bot/ /app/bot/
COPY --chown=app:app api/ /app/api/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --package api
CMD ["fastapi", "run", "--host", "0.0.0.0", "api/main.py"]
When I run my container I'm getting the following error which indicated to me that none of the packages installed.
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "fastapi": executable file not found in $PATH: unknown.
I verified this by opening a shell in the container
app@612b3a28fa65:/app$ uv pip list
app@612b3a28fa65:/app$ uv sync --package api
Resolved 54 packages in 2ms
Audited in 0.00ms
app@612b3a28fa65:/app$
I've noticed that I can force the container to install packages if I remove the uv.lock and the --frozen tag, but that not desirable for having truly reproducible builds.
I have a project that is making use of the
uv
workspaces feature. It has the following structureThis is my root
pyproject.toml
The
agent
package is installed by the other two apps.I need to build a docker image that setups up the
api
package so I modified the cached example in the docs.When I run my container I'm getting the following error which indicated to me that none of the packages installed.
I verified this by opening a shell in the container
I've noticed that I can force the container to install packages if I remove the
uv.lock
and the--frozen
tag, but that not desirable for having truly reproducible builds.