# Copyright (c) 2026 CoReason, Inc
#
# This software is proprietary and dual-licensed
# Licensed under the Prosperity Public License 3.0 (the "License")
# A copy of the license is available at <https://prosperitylicense.com/versions/3.0.0>
# For details, see the LICENSE file
# Commercial use beyond a 30-day trial requires a separate license
#
# Source Code: <https://github.com/CoReason-AI/coreason-runtime>

# Build stage with BuildKit caching to speed up local compilation
FROM rust:1.80-bookworm AS builder
WORKDIR /usr/src/claw-code
COPY claw-code /usr/src/claw-code
RUN --mount=type=cache,target=/usr/local/cargo/registry \
    --mount=type=cache,target=/usr/src/claw-code/target \
    cargo build --release && \
    cp /usr/src/claw-code/target/release/claw /usr/src/claw-code/claw

# Runner stage
FROM python:3.12-slim
WORKDIR /app
COPY --from=builder /usr/src/claw-code/claw /app/claw
COPY server.py /app/server.py

# Install dependencies for fastapi server and for executing test scripts (numpy, pymdp)
RUN pip install --no-cache-dir fastapi uvicorn pydantic numpy pymdp

EXPOSE 9000
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "9000"]
