๐ Gitea Infrastructure on AWS
July 26, 2025 ยท View on GitHub
Production-ready Gitea Git hosting platform deployed on AWS with automated CI/CD
๐ Table of Contents
- ๐งฉ Infrastructure Components
- ๐ง Application Details
- โจ Key Features
- ๐ Quick Start
- ๐ Monitoring
- ๐ Security
๐งฉ Infrastructure Components
๐ณ Container Orchestration
| Service | Purpose | Key Features |
|---|---|---|
| Amazon ECS | Container orchestration platform | Fargate serverless, auto-scaling, health checks |
| Amazon ECR | Private Docker registry | Vulnerability scanning, lifecycle policies, secure access |
| ECS Service | Manages container deployment | Rolling updates, desired count management |
๐พ Storage & Database
|
๐๏ธ Amazon EFS
|
๐ Amazon RDS PostgreSQL
|
๐ Security & Configuration
AWS Systems Manager Parameter Store
Centralized, encrypted storage for:
- Database credentials
- API keys and secrets
- Application configuration
- Environment variables
๐ Load Balancing & SSL
Traffic Flow:
Internet โ Route 53 โ Application Load Balancer โ ECS Containers
โ
SSL Certificate (ACM) โ HTTPS Encryption
- Application Load Balancer: Health checks, traffic distribution
- AWS Certificate Manager: Automated SSL certificate management
- Route 53: DNS management with failover capabilities
โ๏ธ CI/CD Pipeline
Jenkins on EC2
โ
โ
โ
๐ง Application Details
๐ฆ Gitea Configuration
Runtime Environment:
Platform: ECS Fargate
Port: 3000 (HTTP)
Database: PostgreSQL with SSL
Storage: EFS mounted at /data
Authentication: Parameter Store secrets
Features:
โ
Git over HTTPS
โ
Web interface
โ
Issue tracking
โ
Pull requests
โ
SSH
๐จ Jenkins Configuration
Infrastructure:
Instance: EC2 t3.medium (Ubuntu 22.04)
Container: Jenkins LTS in Docker
Backup: Automated daily S3 sync
Capabilities:
โ
Docker-in-Docker builds
โ
ECR integration
โ
AWS CLI access
โ
Automatic restoration
โจ Key Features
๐ High Availability
๐ Enterprise Security
|
๐ Scalability
๐พ Backup & Recovery
|
๐ Quick Start
Prerequisites
# Required tools
terraform --version # >= 1.0
aws --version # AWS CLI configured
Deployment Steps
1๏ธโฃ Deploy S3 Storage (Jenkins Backups)
cd jenkins-s3/
terraform init
terraform plan
terraform apply
2๏ธโฃ Deploy Gitea Infrastructure
cd ../gitea/
terraform init
terraform plan
terraform apply
# Note: Creates ECR, ECS, EFS, RDS, IAM roles
3๏ธโฃ Deploy Load Balancer & SSL
cd ../gitea-alb/
terraform init
terraform plan
terraform apply
# Outputs: DNS name and HTTPS URL
4๏ธโฃ Deploy Jenkins CI/CD
cd ../jenkins-ec2/
terraform init
terraform plan
terraform apply
# Outputs: Jenkins URL and SSH command
๐ Access Your Services
| Service | URL | Purpose |
|---|---|---|
| Gitea | https://my-gitea.pp.ua | Git hosting & web interface |
| Jenkins | http://jenkins-gitea.pp.ua:8080 | CI/CD pipeline management |
๐ Monitoring
CloudWatch Integration
Monitoring Stack:
๐ Container Insights: ECS cluster metrics
๐ Log Groups: Centralized application logs
๐จ Health Checks: ALB target health monitoring
๐ Custom Metrics: Database performance insights
Key Metrics to Watch
- ECS service CPU/Memory utilization
- RDS connection count and query performance
- EFS throughput and IOPS
- ALB response times and error rates
๐ Security
๐ก๏ธ Security Best Practices Implemented
| Layer | Security Measures |
|---|---|
| Network | VPC isolation, Security Groups, Private subnets |
| Data | Encryption at rest (EFS, RDS, S3), SSL/TLS in transit |
| Access | IAM roles, least privilege principle, no hardcoded secrets |
| Container | Private ECR, vulnerability scanning, non-root users |
๐ Secrets Management
All sensitive data is stored in AWS Systems Manager Parameter Store:
- Database credentials (encrypted)
- Application secrets and API keys
- SSL certificates and domain configuration
๐ก Need Help?
Built with โค๏ธ using AWS + Terraform + Open Source
This infrastructure follows AWS Well-Architected Framework principles
This infrastructure project provisions a complete AWS-based environment for running Gitea (a self-hosted Git service) and Jenkins (a CI/CD automation server) using Terraform. It includes container orchestration, persistent storage, secret management, backups, and secure public access via HTTPS.
๐๏ธ Components Overview
| Component | Purpose |
|---|---|
| ECS | Runs the Gitea container using AWS Fargate |
| ECR | Stores the custom Gitea container image |
| EFS | Provides persistent, encrypted storage for Gitea |
| RDS | PostgreSQL backend for Gitea database |
| S3 | Stores Jenkins backups, versioned and encrypted |
| IAM | Grants EC2 and ECS access to needed services (S3, ECR, etc.) |
| Parameter Store | Holds all Gitea secrets and credentials securely |
| ALB + ACM | Public HTTPS access to Gitea via a load balancer and a self-signed cert |
| Route 53 | DNS zone management and custom domain routing |
| EC2 | Runs the Jenkins server via Docker, initialized via user_data |
๐ Gitea Deployment (ECS + Fargate)
- Gitea runs inside a container defined in
task-definition.json, hosted on ECS Fargate. - Application data is mounted via EFS, ensuring persistent
/data. - Secrets like DB credentials and admin account info are securely pulled from SSM Parameter Store.
- Public access is managed via Application Load Balancer (ALB) with:
- Automatic HTTP โ HTTPS redirection
- Self-signed SSL certificate provisioned via ACM
- Domain mapping via Route 53
๐ง Jenkins Deployment (EC2 + Docker)
- Jenkins runs in a Docker container on an EC2 instance, provisioned with:
- SSH access
- Docker and AWS CLI pre-installed
- Automatic restore from S3 if backup is available
- Daily backups are uploaded to S3, versioned and encrypted
- EC2 instance uses an IAM role with permissions to read/write S3 and access ECR
๐ Secrets Management (Parameter Store)
Secrets are stored under /gitea/ namespace and injected into the Gitea container at runtime:
- Database host, user, password
- Admin username, password, email
- Security keys (e.g.
SECRET_KEY,INSTALL_LOCK)
๐ฆ S3 Usage
- Bucket:
my-jenkins-storage - Used to store and version Jenkins backup data
- Public access is fully blocked
- Server-side encryption is enforced with AES256
๐ Additional Notes
- All services are deployed in
us-east-1 - Default VPC and subnets are used for quick setup
- Jenkins can be accessed at
[http://<EC2_PUBLIC_IP>:8080](http://jenkins-gitea.pp.ua:8080 - Gitea is available at
https://my-gitea.pp.ua