dave_agent/Dockerfile

47 lines
1.8 KiB
Docker
Executable File

# --- Stage 1: Builder ---
# This stage prepares a consistent dependency layer and installs the application
# in a non-editable format. It serves as the common foundation for both
# development and production images to ensure consistency.
FROM python:3.11-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y git && \
pip install uv
COPY pyproject.toml ./
COPY src ./src
# Install the application and all its dependencies, including dev/tools.
# This creates a single, cacheable layer for all dependencies.
RUN uv pip install --system .
RUN uv pip install --system ".[dev,tools]"
# --- Stage 2: Development Image ---
# This is the final image for the local development environment.
# It inherits directly from the builder, ensuring all tools (like git and uv)
# and dependencies are present. It then re-installs the application in
# "editable" mode to enable hot-reloading with local volume mounts.
FROM builder AS development
# Re-install the application in editable mode (-e) to link the source code.
RUN uv pip install --system -e .
RUN uv pip install --system -e ".[dev,tools]"
# Expose the application port and the debug port.
EXPOSE 8000 5678
# --- Stage 3: Production Image ---
# This is the final, optimized image for production.
# It starts from a clean base and copies only the necessary artifacts from the builder,
# resulting in a smaller and more secure final image.
FROM python:3.11-slim AS production
WORKDIR /app
# Copy the pre-installed dependencies from the builder stage.
COPY --from=builder /usr/local/ /usr/local/
# Copy the source code from the builder stage to ensure it's the same version.
COPY --from=builder /app/src ./src
# Expose the application port.
EXPOSE 8000
# Set the default command to run when the container starts.
CMD ["adk", "web", "src", "--host", "0.0.0.0"]