5.8 KiB
5.8 KiB
Harbor Registry Configuration
This folder contains the configuration files for the Harbor Registry setup used in the CI/CD pipeline.
Files
docker-compose.yml
- Docker Compose configuration for Harbor servicesnginx.conf
- Nginx reverse proxy configuration for SSL termination and routingharbor.yml
- Harbor configuration fileREADME.md
- This file
Architecture
This setup uses a hybrid approach for optimal maintainability and security:
Repository Files (Version Controlled)
- Configuration files in
/opt/APP_NAME/registry/
- Easy to update via git pull
- Version controlled and tracked
System Files (Not Version Controlled)
- SSL certificates in
/etc/ssl/registry/
- Authentication files in
/etc/registry/auth/
- Registry data in Docker volume
/var/lib/registry
Usage
The setup process will:
- Clone the repository to
/opt/APP_NAME/
- Create system directories for certificates and auth
- Generate SSL certificates in
/etc/ssl/registry/
- Create authentication files in
/etc/registry/auth/
- Start the registry services using the hybrid configuration
Configuration Notes
- Registry: Runs on port 5000 with HTTPS
- Nginx: Provides SSL termination and reverse proxy on port 8080
- Registry UI: Web interface accessible via nginx on port 8080
- Authentication: Uses htpasswd for push authentication
- Storage: Uses Docker volume for persistent data
- Configuration: Version controlled in repository
- Certificates: Stored in system SSL directory
Security
- SSL certificates are self-signed and stored in system SSL directory
- Authentication files are stored in system auth directory
- Configuration is version controlled and easily auditable
- All communication uses HTTPS
- Clear separation between config, auth, and data
Harbor Registry Setup
This directory contains the configuration for Harbor, an enterprise-grade container registry that provides:
- Public read access - Anyone can pull images without authentication
- Authenticated write access - Only authenticated users can push images
- Web UI - Modern web interface for managing images
- Vulnerability scanning - Built-in security scanning with Trivy
- Role-based access control - Fine-grained permissions
- Multi-tenancy - Project-based organization
Prerequisites
- Docker and Docker Compose installed
- SSL certificates for HTTPS (recommended for production)
- At least 4GB RAM and 10GB disk space
Configuration
1. Update Configuration Files
Before starting Harbor, update the following files:
harbor.yml
: Updatehostname
andharbor_admin_password
docker-compose.yml
: Update secrets and passwords
2. SSL Certificates
Place your SSL certificates in /etc/ssl/registry/
:
registry.crt
- SSL certificateregistry.key
- SSL private key
3. Environment Variables
Set the following environment variables:
export HARBOR_HOSTNAME=YOUR_CI_CD_IP
export HARBOR_ADMIN_PASSWORD=your-secure-password
export DB_PASSWORD=your-db-password
Installation
-
Stop existing registry (if running):
docker compose down
-
Start Harbor:
docker compose up -d
-
Wait for startup (can take 2-3 minutes):
docker compose logs -f
Initial Setup
-
Access Harbor UI: https://YOUR_CI_CD_IP:8080
-
Login with default credentials:
- Username:
admin
- Password:
Harbor12345
(or your configured password)
- Username:
-
Change admin password on first login
Configuration for Public Read, Authenticated Write
1. Create a Public Project
- Go to Projects → New Project
- Set Project Name:
public
- Set Access Level:
Public
- Click OK
2. Create a Private Project (for authenticated writes)
- Go to Projects → New Project
- Set Project Name:
private
- Set Access Level:
Private
- Click OK
3. Create Users
- Go to Administration → Users → New User
- Create users with appropriate roles:
- Developer: Can push/pull to private projects
- Guest: Can only pull from public projects
Usage
Docker Login
docker login YOUR_CI_CD_IP:8080
Push Images
# Tag your image
docker tag myimage:latest YOUR_CI_CD_IP:8080/public/myimage:latest
# Push to public project (requires authentication)
docker push YOUR_CI_CD_IP:8080/public/myimage:latest
Pull Images
# Pull from public project (no authentication required)
docker pull YOUR_CI_CD_IP:8080/public/myimage:latest
Security Features
- Vulnerability Scanning: Automatic CVE scanning with Trivy
- Image Signing: Content trust and image signing
- RBAC: Role-based access control
- Audit Logs: Complete audit trail of all operations
Maintenance
Backup
# Backup Harbor data
docker compose exec harbor-db pg_dump -U postgres registry > backup.sql
Update
# Pull latest images
docker compose pull
# Restart services
docker compose up -d
Logs
# View all logs
docker compose logs
# View specific service logs
docker compose logs harbor-core
Troubleshooting
Common Issues
- Startup takes too long: Harbor needs time to initialize database and download vulnerability databases
- SSL certificate errors: Ensure certificates are properly placed and have correct permissions
- Authentication issues: Check user permissions and project access levels
Health Check
# Check service status
docker compose ps
# Check Harbor health
curl -k https://YOUR_CI_CD_IP:8080/api/v2.0/health