# ── Falah Mobile — Auto-Healer Agent ──────────────────────────
# Dedicated container that monitors the app stack and auto-fixes faults.
# Runs alongside the main app container with access to Docker socket.
# ──────────────────────────────────────────────────────────────

FROM alpine:3.19

RUN apk add --no-cache curl docker-cli bash jq

WORKDIR /app

COPY auto-heal-agent.sh /app/auto-heal-agent.sh
RUN chmod +x /app/auto-heal-agent.sh

# Runtime state
RUN mkdir -p /var/log/falah /var/state/falah

# Monitor interval in seconds (default 30)
ENV CHECK_INTERVAL=30
ENV CONTAINER_NAME=falah-mobile-staging
ENV HEALTH_URL=http://localhost:4014/mobile/api/health
ENV GATEWAY_URL=http://localhost:7878/mobile/api/health
ENV MAX_RESTARTS_PER_HOUR=3

CMD ["/app/auto-heal-agent.sh"]
