|
1 | | -# Build stage |
2 | | -FROM python:3.11.9-slim as builder |
3 | | - |
4 | | -ENV POETRY_HOME="/opt/poetry" |
5 | | -ENV POETRY_NO_INTERACTION=1 |
6 | | -ENV POETRY_VIRTUALENVS_CREATE=false |
7 | | -ENV PATH="$POETRY_HOME/bin:$PATH" |
8 | | - |
9 | | -RUN apt-get update \ |
10 | | - && apt-get install -y --no-install-recommends \ |
11 | | - build-essential \ |
12 | | - cmake \ |
13 | | - git \ |
14 | | - graphviz-dev \ |
15 | | - libgraphviz-dev \ |
16 | | - pkg-config \ |
17 | | - curl \ |
18 | | - && curl -sSL https://install.python-poetry.org | python - |
| 1 | +# ============================================================================== |
| 2 | +# ARLA Project Dockerfile - Optimized for Development Speed |
| 3 | +# ============================================================================== |
19 | 4 |
|
20 | | -WORKDIR /app |
21 | | -COPY . . |
22 | | -RUN poetry install --without dev |
23 | | - |
24 | | -# Runtime stage |
25 | 5 | FROM python:3.11.9-slim |
26 | 6 |
|
27 | | -RUN apt-get update \ |
28 | | - && apt-get install -y --no-install-recommends \ |
29 | | - graphviz \ |
30 | | - gifsicle \ |
| 7 | +# Set environment variables for Poetry |
| 8 | +ENV POETRY_HOME="/opt/poetry" \ |
| 9 | + POETRY_NO_INTERACTION=1 \ |
| 10 | + POETRY_VIRTUALENVS_CREATE=true \ |
| 11 | + POETRY_VIRTUALENVS_IN_PROJECT=true \ |
| 12 | + POETRY_CACHE_DIR=/opt/poetry-cache \ |
| 13 | + PATH="$POETRY_HOME/bin:$PATH" |
| 14 | + |
| 15 | +# Install system dependencies |
| 16 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 17 | + build-essential \ |
| 18 | + cmake \ |
| 19 | + git \ |
| 20 | + graphviz \ |
| 21 | + graphviz-dev \ |
| 22 | + libgraphviz-dev \ |
| 23 | + pkg-config \ |
| 24 | + curl \ |
| 25 | + gifsicle \ |
| 26 | + && curl -sSL https://install.python-poetry.org | python - \ |
| 27 | + && apt-get clean \ |
31 | 28 | && rm -rf /var/lib/apt/lists/* |
32 | 29 |
|
| 30 | +# Set working directory |
33 | 31 | WORKDIR /app |
34 | | -COPY --from=builder /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/ |
35 | | -COPY --from=builder /usr/local/bin/ /usr/local/bin/ |
36 | | -COPY --from=builder /app . |
37 | 32 |
|
| 33 | +# Create the full directory structure that Poetry expects |
| 34 | +RUN mkdir -p \ |
| 35 | + /app/agent-core/src/agent_core \ |
| 36 | + /app/agent-engine/src/agent_engine \ |
| 37 | + /app/agent-sim/src/agent_sim \ |
| 38 | + /app/agent-concurrent/src/agent_concurrent \ |
| 39 | + /app/agent-persist/src/agent_persist \ |
| 40 | + /app/simulations \ |
| 41 | + /app/data \ |
| 42 | + /app/mlruns |
| 43 | + |
| 44 | +# Copy all pyproject.toml files first for dependency resolution |
| 45 | +COPY pyproject.toml poetry.lock* ./ |
| 46 | +COPY agent-core/pyproject.toml ./agent-core/pyproject.toml |
| 47 | +COPY agent-engine/pyproject.toml ./agent-engine/pyproject.toml |
| 48 | +COPY agent-sim/pyproject.toml ./agent-sim/pyproject.toml |
| 49 | +COPY agent-concurrent/pyproject.toml ./agent-concurrent/pyproject.toml |
| 50 | +COPY agent-persist/pyproject.toml ./agent-persist/pyproject.toml |
| 51 | + |
| 52 | +# Create minimal __init__.py files so packages can be found |
| 53 | +RUN touch /app/agent-core/src/agent_core/__init__.py && \ |
| 54 | + touch /app/agent-engine/src/agent_engine/__init__.py && \ |
| 55 | + touch /app/agent-sim/src/agent_sim/__init__.py && \ |
| 56 | + touch /app/agent-concurrent/src/agent_concurrent/__init__.py && \ |
| 57 | + touch /app/agent-persist/src/agent_persist/__init__.py |
| 58 | + |
| 59 | +# Install all dependencies including local packages in editable mode |
| 60 | +# This will work now because the directory structure exists |
| 61 | +RUN $POETRY_HOME/bin/poetry install --without dev --no-root && \ |
| 62 | + $POETRY_HOME/bin/poetry run pip install -e ./agent-core -e ./agent-engine -e ./agent-sim -e ./agent-concurrent -e ./agent-persist && \ |
| 63 | + rm -rf $POETRY_CACHE_DIR |
| 64 | + |
| 65 | +# Set Python path |
| 66 | +ENV PYTHONPATH="/app/agent-core/src:/app/agent-engine/src:/app/agent-sim/src:/app/agent-concurrent/src:/app/agent-persist/src:/app/simulations" |
| 67 | + |
| 68 | +# Default command - keep container running |
38 | 69 | CMD ["tail", "-f", "/dev/null"] |
0 commit comments