# OneDev All-in-One DevOps

> Self-hosted DevOps platform with Git, CI/CD, and project management.

- Category: DevOps & CI/CD
- Difficulty: intermediate
- Components: onedev, postgresql
- Tags: onedev, devops, git, ci-cd, project-management
- Source: https://docker.recipes/devops/onedev-devops

## Overview

OneDev is a self-hosted all-in-one DevOps platform that combines Git repository management, continuous integration/continuous deployment (CI/CD), and project management into a single cohesive solution. Created as an alternative to managing multiple disparate tools, OneDev provides built-in issue tracking, pull request workflows, build automation, and project boards while maintaining complete control over your development infrastructure. Unlike cloud-based solutions, OneDev runs entirely on your own infrastructure, ensuring data sovereignty and customization flexibility.

This stack pairs OneDev with PostgreSQL to create a production-ready development platform. PostgreSQL serves as OneDev's primary database, storing Git metadata, issue tracking data, build configurations, and user management information. The combination leverages PostgreSQL's ACID compliance and robust transaction support to ensure data integrity across all DevOps operations, from code commits to build pipeline executions. PostgreSQL's advanced indexing and query optimization capabilities handle OneDev's complex relational queries for repository searches, build history analysis, and project reporting.

This configuration is ideal for development teams seeking to consolidate their toolchain without sacrificing functionality or control. Organizations migrating from GitHub/GitLab combinations or those requiring on-premises DevOps solutions will find this stack particularly valuable. The setup provides enterprise-grade Git hosting, sophisticated CI/CD pipelines with YAML configuration, and integrated project management tools that rival commercial offerings while maintaining complete administrative control.

## Features

- Built-in Git server with advanced repository management and branch protection rules
- YAML-based CI/CD pipelines with Docker-in-Docker build execution capabilities
- Integrated issue tracking with customizable workflows and project boards
- Pull request management with code review tools and merge conflict resolution
- PostgreSQL-backed data persistence ensuring ACID compliance for all DevOps operations
- SSH Git access on port 6611 for command-line repository operations
- Docker socket mounting enabling containerized build environments
- Comprehensive user management with role-based access control and team permissions

## Use cases

- Small to medium development teams consolidating from multiple DevOps tools into a single platform
- Organizations requiring on-premises Git hosting with integrated CI/CD capabilities
- Companies migrating from cloud-based solutions to maintain data sovereignty and control
- Development teams needing tight integration between source control and project management
- Startups seeking enterprise DevOps functionality without per-user licensing costs
- Educational institutions teaching DevOps practices with a complete, self-contained platform
- Open source projects requiring robust hosting with integrated community contribution workflows

## Prerequisites

- Docker host with minimum 2GB RAM (OneDev requires 1GB+ and PostgreSQL needs 512MB+)
- Available ports 6610 (OneDev web interface) and 6611 (SSH Git access)
- Docker socket access for OneDev's containerized build system
- POSTGRES_PASSWORD environment variable configured for database authentication
- Basic understanding of Git workflows and CI/CD pipeline concepts
- Sufficient disk space for Git repositories and build artifacts (recommend 20GB+ initial allocation)

## docker-compose.yml

```yaml
services:
  postgres:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=onedev
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=onedev
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - onedev_net

  onedev:
    image: 1dev/server:latest
    ports:
      - "6610:6610"
      - "6611:6611"
    environment:
      - hibernate_dialect=io.onedev.server.persistence.PostgreSQLDialect
      - hibernate_connection_driver_class=org.postgresql.Driver
      - hibernate_connection_url=jdbc:postgresql://postgres:5432/onedev
      - hibernate_connection_username=onedev
      - hibernate_connection_password=${POSTGRES_PASSWORD}
    volumes:
      - onedev_data:/opt/onedev
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - postgres
    networks:
      - onedev_net

volumes:
  postgres_data:
  onedev_data:

networks:
  onedev_net:
```

## .env

```bash
# OneDev
POSTGRES_PASSWORD=secure_postgres_password

# OneDev at http://localhost:6610
# SSH at localhost:6611
# Complete setup wizard on first access
```

## Usage notes

- OneDev at http://localhost:6610
- SSH at port 6611
- Complete setup wizard first
- Built-in CI/CD with YAML
- Issue tracking and boards

## Troubleshooting

- OneDev startup fails with database connection errors: Ensure PostgreSQL container is fully initialized before OneDev starts, increase depends_on wait time if necessary
- Git clone/push operations fail on port 6611: Verify SSH port 6611 is accessible and not blocked by firewall, check Docker host port binding configuration
- Build pipelines fail with Docker socket errors: Confirm /var/run/docker.sock is properly mounted and accessible, ensure Docker daemon is running on host
- OneDev web interface shows 'hibernate.dialect' errors: Verify PostgreSQL environment variables match OneDev's database connection settings exactly
- Performance issues during large repository operations: Increase PostgreSQL shared_buffers and effective_cache_size, consider allocating more memory to both containers
- Setup wizard repeatedly fails: Clear onedev_data volume and restart containers, ensure POSTGRES_PASSWORD is consistently set across both services

