Build a Lightweight Internal Git and Script Catalog with Gitea
A practical setup for a lightweight internal Git repository and script catalog using Gitea, a self-hosted Git service.
Expected Outcome
A working internal Git repository hosted on Gitea, allowing for easy script management and version control.
Assumptions
- A server or cloud instance with at least 1GB of RAM
- Docker installed on the server
- Basic knowledge of Git and command line operations
Bill of Materials
- Docker
- Docker Compose
- A domain name or IP address for accessing Gitea
- SSL certificate (optional, for secure access)
Build Steps
- Install Docker and Docker Compose
Ensure Docker and Docker Compose are installed on your server. This will allow you to run Gitea in a containerized environment.
Changes system state: review before running
sudo apt-get update sudo apt-get install -y docker.io sudo systemctl start docker sudo systemctl enable docker sudo apt-get install -y docker-compose
- Create a Docker Compose file for Gitea
Set up a Docker Compose file to define the Gitea service and its dependencies.
Safe to run: read-only
mkdir -p ~/gitea cd ~/gitea nano docker-compose.yml
- Start Gitea using Docker Compose
Run the Docker Compose command to start Gitea.
Changes system state: review before running
docker-compose up -d
- Access Gitea web interface
Open your web browser and navigate to the Gitea instance to complete the setup.
Example pattern only. Adjust for your environment before running.
http://your-domain.com:3000
- Create a new repository for scripts
Once logged in, create a new repository in Gitea to store your scripts. Manual action: Click on 'New Repository' in the Gitea dashboard; Click 'Create Repository'.
Example pattern only. Adjust for your environment before running.
Fill in the repository name, description, and set it to private or public based on your preference
- Clone the repository locally
Clone the newly created repository to your local machine for script management.
Safe to run: read-only
git clone http://your-domain.com:3000/username/repository-name.git
- Add scripts to the repository
Add your scripts to the cloned repository and push them back to Gitea.
Safe to run: read-only
cd repository-name touch script.sh git add script.sh git commit -m 'Add initial script' git push origin master
Validation
- Access the Gitea web interface and confirm that the repository is listed.
- Check that the scripts can be cloned, edited, and pushed successfully.
Troubleshooting
- If a step fails, capture the exact command, exit code, and log line before retrying or changing the design.
- Use `docker compose ps` and `docker compose logs <service>` to separate image, environment, port, and volume problems.
Cleanup or Rollback
- Keep a copy of working configuration, compose files, scripts, and service credentials before removing containers, packages, or data directories.
- Stop test containers with `docker compose down` only after confirming which volumes contain persistent data.
- Rollback by redeploying the previous compose file or image tag and restoring the saved environment file.
Next Improvements
- Explore Gitea's features such as issue tracking, pull requests, and wiki.
- Consider setting up webhooks for automated deployments or CI/CD integration.