[Unit]
Description=P5G Marvis container
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
Restart=always
RestartSec=5
TimeoutStartSec=0
Environment=MARVIS_PROMETHEUS_URL=http://127.0.0.1:9090
Environment=MARVIS_PROMETHEUS_PREFIX=/prometheus
Environment=MARVIS_ALERTMANAGER_URL=http://127.0.0.1:9093
Environment=MARVIS_AI_MODE=rule
Environment=MARVIS_OPENAI_API_KEY=
Environment=MARVIS_OPENAI_BASE_URL=https://api.openai.com
Environment=MARVIS_OPENAI_MODEL=gpt-4o-mini
Environment=MARVIS_OLLAMA_URL=http://127.0.0.1:11434
Environment=MARVIS_OLLAMA_MODEL=llama3
EnvironmentFile=-/etc/p5g-marvis/marvis.env

ExecStartPre=-/usr/bin/docker rm -f p5g-marvis
ExecStart=/usr/bin/docker run \
  --name p5g-marvis \
  --network host \
  --env MARVIS_PROMETHEUS_URL \
  --env MARVIS_PROMETHEUS_PREFIX \
  --env MARVIS_ALERTMANAGER_URL \
  --env MARVIS_AI_MODE \
  --env MARVIS_OPENAI_API_KEY \
  --env MARVIS_OPENAI_BASE_URL \
  --env MARVIS_OPENAI_MODEL \
  --env MARVIS_OLLAMA_URL \
  --env MARVIS_OLLAMA_MODEL \
  p5g-marvis:latest
ExecStop=/usr/bin/docker stop p5g-marvis

[Install]
WantedBy=multi-user.target
