Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Abendgast/Gitea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸš€ Gitea Infrastructure on AWS

AWS Terraform Docker Gitea Jenkins

Production-ready Gitea Git hosting platform deployed on AWS with automated CI/CD


πŸ“‹ Table of Contents


🧩 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

  • Shared persistent storage
  • Multi-AZ availability
  • Encryption in transit/rest
  • POSIX-compliant file system

🐘 Amazon RDS PostgreSQL

  • Managed database service
  • Automated backups
  • Multi-AZ deployment
  • Performance monitoring

πŸ” 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

Jenkins Flow β†’ Build β†’ Registry β†’ Deploy


πŸ”§ 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

  • βœ… Multi-AZ deployment
  • βœ… Auto-scaling containers
  • βœ… Database redundancy
  • βœ… Load balancer health checks

πŸ”’ Enterprise Security

  • βœ… Encrypted storage & transit
  • βœ… IAM role-based access
  • βœ… Private container registry
  • βœ… Network segmentation

πŸ“ˆ Scalability

  • βœ… Serverless containers (Fargate)
  • βœ… Auto-growing file system
  • βœ… Database auto-scaling
  • βœ… Elastic load balancing

πŸ’Ύ Backup & Recovery

  • βœ… Automated Jenkins backups
  • βœ… RDS point-in-time recovery
  • βœ… EFS built-in redundancy
  • βœ… Infrastructure as Code

πŸš€ 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?

Issues Documentation Terraform


Built with ❀️ using AWS + Terraform + Open Source

This infrastructure follows AWS Well-Architected Framework principles

# AWS Infrastructure for Gitea and Jenkins

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

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published