services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    user: "1000:1000"
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--storage.tsdb.retention.time=2h'
      - '--storage.tsdb.min-block-duration=2h'
      - '--storage.tsdb.max-block-duration=2h'
      - '--web.enable-lifecycle'
    volumes:
      - /docker/monitoring/prometheus/config:/etc/prometheus
      - /docker/monitoring/prometheus/data:/prometheus
    ports:
      - "9090:9090"

  thanos-sidecar:
    image: thanosio/thanos:v0.34.0
    container_name: thanos-sidecar
    user: "1000:1000"
    environment:
      - OBJSTORE_CONFIG={"type":"${THANOS_STOR_TYPE}","config":{"bucket":"THANOS_S3_BUCKET","endpoint":"$THANOS_S3_ENDPOINT","access_key":"${S3_KEY}","secret_key":"${S3_SECRET}","insecure":${THANOS_S3_INSECURE}}}
    command:
      - 'sidecar'
      - '--tsdb.path=/prometheus'
      - '--prometheus.url=$PROMETHEUS_URL'
      - '--objstore.config=$$(OBJSTORE_CONFIG)'
    volumes:
      - /docker/monitoring/prometheus/data:/prometheus
    ports:
      - "10901:10901"