
services:
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    restart: unless-stopped
    networks:
      - dokploy-network
    ports:
      - "5433:5432"
    volumes:
      - dbdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
      interval: 1s
      timeout: 5s
      retries: 10
  migrate:
    image: migrate/migrate:latest
    depends_on:
      db:
        condition: service_healthy
    volumes:
      - ./migrations:/migrations:ro
    networks:
      - dokploy-network
    command:
      [
        "-verbose",
        "-path", "/migrations",
        "-database", "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable",
        "up"
        
      ]
    restart: "no"
      
networks:
  dokploy-network:
    external: true
      
volumes:
  dbdata: