How to Deploy a Lightweight Gitea Git Server with Docker for AI Platforms
This guide walks through deploying the lightweight Gitea Git service with Docker, configuring MySQL, setting up the web interface, creating repositories, generating access tokens, and accessing its REST API, offering a resource‑efficient alternative to GitLab for AI model hosting platforms.
Background and Motivation
When building an AI model‑hosting platform similar to ModelScope, each project needs an independent Git repository service. The initial choice of GitLab quickly hit a resource ceiling, consuming up to 10 GB of memory, which is unsustainable for a lightweight deployment.
Choosing Gitea
Switching to Gitea, a lightweight self‑hosted Git solution, reduced memory usage to around 600 MB and provided a full set of REST APIs, enabling deep integration with the AI platform.
Prerequisites
Database (MySQL / PostgreSQL / SQLite) – required for storing core data such as users, repositories, issues, PRs, permissions, and LFS metadata. The tutorial uses MySQL 8.
S3 / MinIO (Object Storage) – optional; used for repository attachments and large files, otherwise local disk is used.
Redis – optional; can serve as cache, session store, or background queue to improve performance.
Docker Installation
Run the following command to start Gitea in a Docker container:
docker run -d --name gitea \
-p 3000:3000 -p 222:22 \
-v /Users/zhangyong/docker/gitea/data:/data \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-e USER_UID=1000 \
-e USER_GID=1000 \
--restart always \
gitea/gitea:latestInitial Setup
After the container starts, open http://localhost:3000. On the first‑run page, configure the database connection (e.g., MySQL 8) and click “Install”. The configuration file is written to /data/gitea/conf/app.ini. Once installed, the login screen appears.
Creating Repositories
The repository creation UI resembles GitHub. Enter a repository name and click “Create”. To clone or push, generate a Personal Access Token (PAT) for a user.
Using the REST API
Visit http://localhost:3000/api/swagger#/repository to explore all Gitea development APIs. These endpoints can be wrapped into custom services, such as a Java client library, to automate repository management.
Conclusion
The comparison chart shows Gitea’s lightweight footprint versus GitLab’s heavyweight requirements. Gitea proved to be a compact, feature‑rich solution that fits the company’s AI platform needs while keeping resource consumption low.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
