164 lines
2.4 KiB
Markdown
164 lines
2.4 KiB
Markdown
# Gitea Self‑Hosted Deployment
|
||
|
||
This repository provides a **simple automated deployment for a self‑hosted Gitea server** using Docker Compose.
|
||
|
||
It is designed to make deploying a production‑ready Git server easy with:
|
||
|
||
- Docker Compose deployment
|
||
- PostgreSQL database
|
||
- Optional SMTP email
|
||
- Optional HTTPS support
|
||
- Automated bootstrap script
|
||
- Persistent data storage
|
||
|
||
|
||
# Requirements
|
||
|
||
Minimum recommended:
|
||
|
||
- Linux server (Ubuntu / Debian)
|
||
- Docker
|
||
- Docker Compose
|
||
- 2 CPU cores
|
||
- 2‑4GB RAM
|
||
- 10GB disk space
|
||
|
||
|
||
# Quick Start
|
||
|
||
Clone the repository:
|
||
```
|
||
git clone https://git.amiirkhl.ir/interanet/gitea-deployment.git
|
||
cd gitea-deployment
|
||
```
|
||
|
||
Run the bootstrap script:
|
||
```
|
||
chmod +x run.sh
|
||
./run.sh
|
||
```
|
||
|
||
On first run the script will:
|
||
- Create `.env` from `.env.sample`
|
||
- Ask you to configure settings
|
||
|
||
Edit `.env`:
|
||
```
|
||
nano .env
|
||
```
|
||
|
||
Set at minimum:
|
||
```
|
||
GITEA_EXTERNAL_URL
|
||
GITEA_ROOT_USER
|
||
GITEA_ROOT_PASSWORD
|
||
GITEA_ROOT_EMAIL
|
||
```
|
||
|
||
Then run again:
|
||
```
|
||
./run.sh
|
||
```
|
||
|
||
|
||
# Access Gitea
|
||
|
||
After deployment:
|
||
```
|
||
http://YOUR_SERVER_IP
|
||
```
|
||
|
||
or
|
||
```
|
||
https://your-domain.com
|
||
```
|
||
|
||
|
||
# Data Persistence
|
||
|
||
All persistent data is stored in:
|
||
```
|
||
./gitea-data
|
||
```
|
||
|
||
Structure:
|
||
```
|
||
gitea-data/
|
||
├─ gitea/
|
||
└─ postgres/
|
||
```
|
||
|
||
Back up this directory to preserve:
|
||
|
||
- repositories
|
||
- database
|
||
- attachments
|
||
- configuration
|
||
|
||
|
||
# Enabling HTTPS
|
||
|
||
Set in `.env`:
|
||
```
|
||
GITEA_EXTERNAL_URL=https://git.example.com
|
||
SSL_CERT_PATH=/etc/letsencrypt/live/git.example.com/fullchain.pem
|
||
SSL_KEY_PATH=/etc/letsencrypt/live/git.example.com/privkey.pem
|
||
```
|
||
|
||
During deployment the `setup-ssl.sh` script will copy certificates to:
|
||
```
|
||
/data/https/cert.pem
|
||
/data/https/key.pem
|
||
```
|
||
|
||
Gitea will automatically use them for HTTPS.
|
||
|
||
|
||
# Managing the Server
|
||
|
||
View logs:
|
||
```
|
||
docker compose logs -f
|
||
```
|
||
|
||
Stop services:
|
||
```
|
||
docker compose down
|
||
```
|
||
|
||
Restart:
|
||
```
|
||
docker compose restart
|
||
```
|
||
|
||
Update Gitea:
|
||
```
|
||
docker compose pull
|
||
docker compose up -d
|
||
```
|
||
|
||
|
||
# Repository Structure
|
||
```
|
||
gitea-deployment
|
||
├─ docker-compose.yml
|
||
├─ run.sh
|
||
├─ .env.sample
|
||
├─ README.md
|
||
└─ scripts
|
||
├─ setup-swap.sh
|
||
└─ setup-ssl.sh
|
||
```
|
||
|
||
|
||
# Notes
|
||
|
||
- The first time Gitea starts it will initialize the database automatically.
|
||
- Admin credentials are configured through `.env`.
|
||
- SMTP is optional but recommended for production.
|
||
|
||
|
||
# License
|
||
|
||
MIT
|