# Scope: isolated runtime verification for backend API + PostgreSQL + .env bootstrap without using project fixed container names.

services:
  postgres:
    image: postgres:17-alpine
    container_name: ocdp-verify-postgres
    restart: "no"
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-ocdp}
      POSTGRES_USER: ${POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
      POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
    ports:
      - "${VERIFY_POSTGRES_PORT:-15432}:5432"
    volumes:
      - ocdp_verify_postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-ocdp}"]
      interval: 5s
      timeout: 5s
      retries: 30
      start_period: 180s
    networks:
      - ocdp-verify-network

  backend:
    image: golang:1.24-alpine
    container_name: ocdp-verify-backend
    restart: "no"
    working_dir: /src
    env_file:
      - path: ../.env
        required: false
    environment:
      ADAPTER_MODE: production
      PORT: 8080
      JWT_SECRET: ${JWT_SECRET:-verify-jwt-secret}
      ENCRYPTION_KEY: ${ENCRYPTION_KEY:-verify-encryption-key}
      DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-ocdp}?sslmode=disable
    ports:
      - "${VERIFY_BACKEND_PORT:-18081}:8080"
    volumes:
      - ../backend:/src
    command: >
      sh -c "
        apk add --no-cache git &&
        go run cmd/api/main.go
      "
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - ocdp-verify-network

networks:
  ocdp-verify-network:
    name: ocdp-verify-network

volumes:
  ocdp_verify_postgres_data:
    name: ocdp-verify-postgres-data
