Skip to main content

Getting Started with Gitea CI/CD Pipeline

· 4 min read
Ahmad Ardiansyah
DevOps Engineer

Selamat datang di panduan Getting Started untuk implementasi CI/CD menggunakan Gitea, Gitea Runner, dan Kubernetes! Dalam artikel ini, kita akan membahas langkah-langkah awal untuk memulai journey DevOps Anda.

Pengenalan

CI/CD (Continuous Integration/Continuous Deployment) telah menjadi standar dalam software development modern. Dengan CI/CD, kita dapat:

  • ✅ Otomasi proses build dan testing
  • ✅ Deployment yang cepat dan reliable
  • ✅ Mengurangi human error
  • ✅ Meningkatkan produktivitas tim
  • ✅ Faster time to market

Mengapa Gitea?

Gitea adalah pilihan yang excellent untuk self-hosted Git service karena:

1. Lightweight & Fast

Gitea ditulis dalam Go dan dikompilasi menjadi single binary yang sangat ringan. Anda bisa menjalankan Gitea dengan resource minimal:

  • CPU: 1 core
  • RAM: 512 MB
  • Storage: 5 GB

2. Easy to Install

Installation Gitea sangat straightforward. Dalam hitungan menit, Anda sudah bisa memiliki Git server yang fully functional.

# Install Gitea in one command
curl -sfL https://get.k3s.io | sh -

3. Built-in CI/CD

Gitea Actions memberikan fitur CI/CD yang powerful, compatible dengan GitHub Actions syntax.

4. Self-Hosted

Full control atas data dan infrastructure. Tidak perlu khawatir tentang privacy atau vendor lock-in.

5. Cost Effective

Open source dan gratis. Perfect untuk startup, SME, atau personal projects.

Mengapa K3s?

K3s adalah lightweight Kubernetes distribution yang ideal untuk:

1. Development & Testing

Quick setup untuk development environment tanpa overhead besar dari full K8s installation.

2. Edge Computing

Perfect untuk IoT dan edge devices dengan resource terbatas.

3. Production Ready

Meskipun lightweight, K3s adalah certified Kubernetes distribution yang production-ready.

4. Single Binary

Seperti Gitea, K3s juga dikompilasi menjadi single binary (~100MB) yang mudah di-deploy.

Arsitektur Overview

Mari kita lihat arsitektur lengkap yang akan kita bangun:

┌─────────────────────────────────────────────────────────┐
│ Developer │
│ git push → Gitea │
└────────────────────┬────────────────────────────────────┘


┌─────────────────────────────────────────────────────────┐
│ Gitea Server │
│ - Repository hosting │
│ - Gitea Actions (CI/CD) │
│ - Webhook management │
└────────────────────┬────────────────────────────────────┘
│ Trigger workflow

┌─────────────────────────────────────────────────────────┐
│ Gitea Runner │
│ - Execute workflows │
│ - Build Docker images │
│ - Run tests │
└────────────────────┬────────────────────────────────────┘
│ Push image

┌─────────────────────────────────────────────────────────┐
│ Docker Registry │
│ - Store container images │
│ - Version management │
└────────────────────┬────────────────────────────────────┘
│ Deploy

┌─────────────────────────────────────────────────────────┐
│ Kubernetes (K3s) Cluster │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Dev │ │ Staging │ │ Production │ │
│ │ Namespace │ │ Namespace │ │ Namespace │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────┘

Quick Start: 30 Menit Setup

Step 1: Install Gitea (10 menit)

# Download Gitea binary
wget -O /tmp/gitea https://dl.gitea.com/gitea/1.21.0/gitea-1.21.0-linux-amd64
sudo mv /tmp/gitea /usr/local/bin/gitea
sudo chmod +x /usr/local/bin/gitea

# Create user and directories
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea

# Start Gitea
sudo systemctl start gitea

Akses http://your-server:3000 untuk complete web-based setup.

Step 2: Install K3s (5 menit)

# Install K3s
curl -sfL https://get.k3s.io | sh -

# Verify installation
sudo k3s kubectl get nodes

Done! Kubernetes cluster Anda sudah running.

Step 3: Setup Gitea Runner (10 menit)

# Download runner
wget -O /tmp/act_runner https://dl.gitea.com/act_runner/latest/act_runner-linux-amd64
sudo mv /tmp/act_runner /usr/local/bin/act_runner
sudo chmod +x /usr/local/bin/act_runner

# Register runner
act_runner register --instance http://your-gitea:3000 --token YOUR_TOKEN

# Start runner
act_runner daemon

Step 4: Create Your First Pipeline (5 menit)

Buat file .gitea/workflows/ci.yml:

name: CI Pipeline

on:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: echo "Running tests..."
- name: Build app
run: echo "Building application..."

Commit dan push - pipeline Anda akan berjalan otomatis!

What's Next?

Setelah basic setup, Anda bisa explore lebih lanjut:

1. Advanced Workflows

  • Multi-stage pipelines
  • Parallel jobs
  • Matrix builds
  • Conditional execution

2. Docker Integration

  • Build container images
  • Push to registry
  • Image scanning
  • Multi-platform builds

3. Kubernetes Deployment

  • Automated deployment
  • Rolling updates
  • Health checks
  • Auto-scaling

4. Security

  • Secrets management
  • RBAC
  • Image signing
  • Vulnerability scanning

5. Monitoring

  • Prometheus metrics
  • Grafana dashboards
  • Log aggregation
  • Alerting

Resources

Documentation

Example Projects

Community

Join our community untuk diskusi dan bantuan:

  • GitHub Discussions: Share experiences dan ask questions
  • Discord Server: Real-time chat dengan community
  • Blog: Regular updates dan tutorials

Conclusion

Memulai dengan Gitea CI/CD pipeline tidak harus complicated. Dengan tools yang tepat dan panduan yang jelas, Anda bisa setup production-ready pipeline dalam waktu singkat.

Key takeaways:

  • ✅ Gitea: Lightweight, powerful, self-hosted
  • ✅ K3s: Easy Kubernetes untuk semua scale
  • ✅ CI/CD: Automation saves time dan reduces errors
  • ✅ Open Source: Full control, no vendor lock-in

Ready to start? Head over to our documentation dan begin your CI/CD journey today!


Questions or feedback? Leave a comment below atau reach out di GitHub!

Happy coding! 🚀