# hello-worker as a Campfire worker image: the whole worker in one image,
# listed in campfire.yaml by its image. No tarball, no runtime image.
#
#   docker build -t hello-worker:0.1.0 .
#
# Build it from a copy of this directory (with [tool.uv.sources] deleted and
# a uv.lock, as the README says); inside the repository the SDK is a path
# dependency outside the build context. A GPU worker starts from a CUDA image
# with uv installed instead.
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
WORKDIR /app

# Dependencies first, so this layer is rebuilt only when the lockfile changes,
# not on every code edit.
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --frozen --no-dev --no-install-project

COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --frozen --no-dev

# The deployment record Campfire reads out of the image (instead of a
# tarball's first member). Model weights can be baked in the same way, in a
# layer above the code.
RUN uv run --no-sync campfire-cli meta -o /campfire/WORKER-META.json

ENV PATH="/app/.venv/bin:$PATH"
# Campfire sets FLARE_PORT (7860) and FLARE_WORKER_CLASS_NAME.
EXPOSE 7860
CMD ["campfire-cli", "serve"]
