Initial commit

This commit is contained in:
2026-07-28 15:44:34 +03:00
commit 8e4ea8a6e6
4 changed files with 129 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
.env
.git
.gitignore
README.md
+19
View File
@@ -0,0 +1,19 @@
# Change these before exposing the server outside your machine.
POSTGRES_USER=gitea
POSTGRES_PASSWORD=replace-with-a-long-random-password
POSTGRES_DB=gitea
# Browser and Git SSH settings
GITEA_DOMAIN=localhost
GITEA_ROOT_URL=http://localhost:3000/
GITEA_SSH_DOMAIN=localhost
GITEA_HTTP_PORT=3000
GITEA_SSH_PORT=2222
# Set to true for a private server after creating your first account.
DISABLE_REGISTRATION=false
REQUIRE_SIGNIN_VIEW=false
# Linux host UID/GID for the rootless image. Keep the defaults on Windows/macOS.
USER_UID=1000
USER_GID=1000
+49
View File
@@ -0,0 +1,49 @@
# Local Git Server
A self-hosted Git server powered by Gitea with a GitHub-style web interface, repository browsing, issues, pull requests, actions, releases, and SSH/HTTP Git access.
## Start it
1. Copy `.env.example` to `.env`.
2. Change `POSTGRES_PASSWORD` in `.env` to a long random value.
3. Start the stack:
```powershell
docker compose up -d
```
4. Open [http://localhost:3000](http://localhost:3000).
5. Create the first account. The first account becomes an administrator.
The Git SSH endpoint is available on port `2222`:
```powershell
git clone ssh://git@localhost:2222/your-user/your-repository.git
```
HTTPS cloning is also available from the repository page:
```powershell
git clone http://localhost:3000/your-user/your-repository.git
```
## Useful commands
```powershell
# View service logs
docker compose logs -f gitea
# Stop containers but keep repositories and database data
docker compose down
# Stop and permanently delete all Git data
docker compose down -v
```
## Production notes
- Put Gitea behind HTTPS with a reverse proxy before exposing it to the internet.
- Use a managed or separately backed-up PostgreSQL instance for important repositories.
- Set `DISABLE_REGISTRATION=true` and `REQUIRE_SIGNIN_VIEW=true` for a private team server.
- Back up both the `gitea_data` and `postgres_data` volumes.
- Update `GITEA_ROOT_URL` and `GITEA_DOMAIN` to the public hostname before deploying.
+57
View File
@@ -0,0 +1,57 @@
services:
db:
image: postgres:16-alpine
container_name: git-server-db
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-gitea}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me-in-env}
POSTGRES_DB: ${POSTGRES_DB:-gitea}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- git-server
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-gitea} -d ${POSTGRES_DB:-gitea}"]
interval: 10s
timeout: 5s
retries: 5
gitea:
image: gitea/gitea:1.24-rootless
container_name: git-server
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
USER_UID: ${USER_UID:-1000}
USER_GID: ${USER_GID:-1000}
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: db:5432
GITEA__database__NAME: ${POSTGRES_DB:-gitea}
GITEA__database__USER: ${POSTGRES_USER:-gitea}
GITEA__database__PASSWD: ${POSTGRES_PASSWORD:-change-me-in-env}
GITEA__server__DOMAIN: ${GITEA_DOMAIN:-localhost}
GITEA__server__ROOT_URL: ${GITEA_ROOT_URL:-http://localhost:3000/}
GITEA__server__SSH_DOMAIN: ${GITEA_SSH_DOMAIN:-localhost}
GITEA__server__SSH_PORT: ${GITEA_SSH_PORT:-2222}
GITEA__service__DISABLE_REGISTRATION: ${DISABLE_REGISTRATION:-false}
GITEA__service__REQUIRE_SIGNIN_VIEW: ${REQUIRE_SIGNIN_VIEW:-false}
ports:
- "${GITEA_HTTP_PORT:-3000}:3000"
- "${GITEA_SSH_PORT:-2222}:2222"
volumes:
- gitea_data:/var/lib/gitea
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
- git-server
volumes:
gitea_data:
postgres_data:
networks:
git-server:
driver: bridge