# documentation: https://docs.onedev.io/
# slogan: Git server with CI/CD, kanban, and packages. Seamless integration. Unparalleled experience.
# category: git
# tags: git, scm, ci, cd, kanban, packages, devops, collaboration, code, repository, management
# logo: svgs/onedev.svg
# port: 6610

services:
  onedev:
    image: 1dev/server:latest
    volumes:
      - onedev-docker-sock:/var/run/docker.sock
      - onedev-data:/opt/onedev
    environment:
      - SERVICE_URL_ONEDEV_6610
      - hibernate_dialect=io.onedev.server.persistence.PostgreSQLDialect
      - hibernate_connection_driver_class=org.postgresql.Driver
      - hibernate_connection_url=jdbc:postgresql://postgres:5432/${POSTGRESQL_DATABASE:-onedev}
      - hibernate_connection_username=${SERVICE_USER_DATABASE}
      - hibernate_connection_password=${SERVICE_PASSWORD_64_DATABASE}
      - initial_user=${SERVICE_USER_ONEDEV}
      - initial_password=${SERVICE_PASSWORD_ONEDEV}
      - initial_email=${ONEDEV_EMAIL:-mail@example.com}
      - initial_server_url=${SERVICE_URL_ONEDEV}
      - initial_ssh_root_url=${SSH_ROOT_URL:-ssh://changeme:22}
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "true"]

  postgres:
    image: postgres:16-alpine
    volumes:
      - onedev-postgresql-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${SERVICE_USER_DATABASE}
      - POSTGRES_PASSWORD=${SERVICE_PASSWORD_64_DATABASE}
      - POSTGRES_DB=${POSTGRESQL_DATABASE:-onedev}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 5s
      timeout: 20s
      retries: 10
