# Synor Economics Service Dockerfile
# Provides pricing oracle, metering, and billing APIs

FROM rust:1.75-bookworm AS builder

WORKDIR /app

# Copy workspace files
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/

# Build the economics service binary
RUN cargo build --release -p synor-economics --features "http-feeds"

# Runtime image
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
    ca-certificates \
    libssl3 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy built binary
COPY --from=builder /app/target/release/synor-economics /usr/local/bin/ 2>/dev/null || true

# Create config directory
RUN mkdir -p /app/config /app/data

# Copy default config
COPY docker/economics-service/config.toml /app/config/

# Environment variables
ENV RUST_LOG=info
ENV CONFIG_PATH=/app/config/config.toml
ENV DATA_PATH=/app/data

# Ports
# 4010 - HTTP API
# 4011 - Metrics
EXPOSE 4010 4011

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:4010/health || exit 1

# For library-only crate, we run a simple health indicator
CMD ["echo", "Economics service ready. Use as library dependency."]
