From 85a98858f1879d7bdf0b41779f525ac6c2a3e679 Mon Sep 17 00:00:00 2001 From: Timmy Date: Mon, 9 Mar 2026 12:34:55 +0800 Subject: [PATCH] Initial commit: Gitea Docker setup --- .gitignore | 1 + README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ start.sh | 5 +++++ 4 files changed, 73 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 start.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8fce603 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac8287e --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# Gitea Docker Setup + +使用 Docker Compose 運行 Gitea Git 服務器。 + +## 服務訪問 + +- **Web 界面**: http://localhost:3000 +- **SSH Git**: localhost:222 + +## 常用命令 + +```bash +# 啟動服務 +./start.sh + +# 停止服務 +docker-compose down + +# 查看日誌 +docker-compose logs -f + +# 重啟服務 +docker-compose restart +``` + +## 數據存儲 + +所有 Gitea 數據存儲在 `./data` 目錄下,包含: +- Git repositories +- 數據庫(默認使用 SQLite) +- 配置文件 +- 用戶上傳的文件 + +## 首次設置 + +1. 啟動服務後訪問 http://localhost:3000 +2. 選擇數據庫類型(SQLite3) +3. 設置管理員帳號 +4. 完成! + +## 備份 + +定期備份 `./data` 目錄即可: +```bash +tar -czf gitea-backup-$(date +%Y%m%d).tar.gz data/ +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e6ddc23 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +networks: + gitea: + external: false + +services: + server: + image: gitea/gitea:latest + container_name: gitea + environment: + - USER_UID=1000 + - USER_GID=1000 + restart: always + networks: + - gitea + volumes: + - ./data:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "3000:3000" + - "222:22" diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..d20d10f --- /dev/null +++ b/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +docker-compose up -d +echo "Gitea 已啟動!" +echo "Web 界面: http://localhost:3000" +echo "SSH Git: localhost:222"