v_11
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
# ── Container user ───────────────────────────────────────────────
|
||||
# Match these to the UID/GID that owns the ./gitea host directory.
|
||||
# On Linux, run `id -u` and `id -g` to find yours.
|
||||
USER_UID=1000
|
||||
USER_GID=1000
|
||||
|
||||
# ── PostgreSQL database ──────────────────────────────────────────
|
||||
POSTGRES_USER=gitea
|
||||
POSTGRES_PASSWORD=change_me_to_a_strong_password
|
||||
POSTGRES_DB=gitea
|
||||
|
||||
# ── Host port mappings ───────────────────────────────────────────
|
||||
# host:container — change the host side if these ports are taken.
|
||||
GITEA_HTTP_HOST_PORT=3000
|
||||
GITEA_SSH_HOST_PORT=222
|
||||
|
||||
# ── Server settings ──────────────────────────────────────────────
|
||||
# For a purely local setup, localhost is fine.
|
||||
GITEA_DOMAIN=localhost
|
||||
GITEA_ROOT_URL=http://localhost:3000/
|
||||
|
||||
# ── Security secrets ─────────────────────────────────────────────
|
||||
# Generate each of these once and keep them stable. Do NOT change
|
||||
# SECRET_KEY after installation or encrypted data becomes unreadable.
|
||||
# docker run -it --rm docker.gitea.com/gitea:1 gitea generate secret SECRET_KEY
|
||||
# docker run -it --rm docker.gitea.com/gitea:1 gitea generate secret INTERNAL_TOKEN
|
||||
GITEA_SECRET_KEY=
|
||||
GITEA_INTERNAL_TOKEN=
|
||||
@@ -0,0 +1,95 @@
|
||||
# Local Gitea Deployment (Docker Compose)
|
||||
|
||||
A local, self-hosted [Gitea](https://docs.gitea.com/) instance running Gitea
|
||||
**1.27.3** with a **PostgreSQL 14** database, following the official Gitea
|
||||
Docker installation docs. All credentials, ports, and secrets live in the
|
||||
`.env` file rather than being hardcoded in the compose file.
|
||||
|
||||
## Files
|
||||
|
||||
- `docker-compose.yml` — service definitions for Gitea + PostgreSQL
|
||||
- `.env` — configuration (credentials, ports, secrets)
|
||||
- `README.md` — this file
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker Engine with Compose v2 (`docker compose`, included in modern Docker).
|
||||
If needed, see the [Compose install instructions](https://docs.docker.com/compose/install/).
|
||||
|
||||
## Setup
|
||||
|
||||
Do the following before bringing the stack up.
|
||||
|
||||
### 1. Generate the security secrets
|
||||
|
||||
Run these two commands and paste each result into the matching empty field in
|
||||
`.env` (`GITEA_SECRET_KEY` and `GITEA_INTERNAL_TOKEN`):
|
||||
|
||||
```
|
||||
docker run -it --rm docker.gitea.com/gitea:1 gitea generate secret SECRET_KEY
|
||||
docker run -it --rm docker.gitea.com/gitea:1 gitea generate secret INTERNAL_TOKEN
|
||||
```
|
||||
|
||||
> **Do not change `SECRET_KEY` after the first install.** Encrypted data in the
|
||||
> database cannot be decrypted if you do.
|
||||
|
||||
### 2. Change the database password
|
||||
|
||||
Replace the placeholder `POSTGRES_PASSWORD` value in `.env` with a strong password.
|
||||
|
||||
### 3. Match the UID/GID
|
||||
|
||||
The setup uses a host volume (`./gitea`), so set `USER_UID` / `USER_GID` in
|
||||
`.env` to whoever owns that directory. On Linux:
|
||||
|
||||
```
|
||||
id -u # -> USER_UID
|
||||
id -g # -> USER_GID
|
||||
```
|
||||
|
||||
Wrong volume permissions are the most common reason the container won't start.
|
||||
|
||||
## Start
|
||||
|
||||
```
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Then open **http://localhost:3000** and finish setup in the browser wizard.
|
||||
|
||||
- If the wizard asks for the **database host**, use `db` (the service name), not `localhost`.
|
||||
- **SSH** is available on host port **222**.
|
||||
- Data persists in `./gitea` and `./postgres` next to the compose file.
|
||||
|
||||
## Common commands
|
||||
|
||||
```
|
||||
docker compose ps # check status
|
||||
docker compose logs # view logs
|
||||
docker compose down # stop and remove containers (volumes/data are kept)
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
|
||||
```
|
||||
# Edit the image version in docker-compose.yml if you pin a specific release
|
||||
docker compose pull # pull new images
|
||||
docker compose up -d # recreate containers with the new images
|
||||
```
|
||||
|
||||
> Make sure your data is volumed outside the container (it is, via `./gitea`
|
||||
> and `./postgres`) before upgrading.
|
||||
|
||||
## Security note
|
||||
|
||||
Keep `.env` out of version control — it holds your secrets and database
|
||||
password. Add it to `.gitignore`:
|
||||
|
||||
```
|
||||
echo ".env" >> .gitignore
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
- [Gitea Docs — Installation with Docker](https://docs.gitea.com/installation/install-with-docker/)
|
||||
- [Gitea Docs — Managing deployments with environment variables](https://docs.gitea.com/installation/install-with-docker/#managing-deployments-with-environment-variables)
|
||||
@@ -0,0 +1,51 @@
|
||||
networks:
|
||||
gitea:
|
||||
external: false
|
||||
|
||||
services:
|
||||
server:
|
||||
image: docker.gitea.com/gitea:1.27.3
|
||||
container_name: gitea
|
||||
restart: always
|
||||
environment:
|
||||
# Container user (match to owner of the ./gitea host volume)
|
||||
- USER_UID=${USER_UID}
|
||||
- USER_GID=${USER_GID}
|
||||
# Database connection
|
||||
- GITEA__database__DB_TYPE=postgres
|
||||
- GITEA__database__HOST=db:5432
|
||||
- GITEA__database__NAME=${POSTGRES_DB}
|
||||
- GITEA__database__USER=${POSTGRES_USER}
|
||||
- GITEA__database__PASSWD=${POSTGRES_PASSWORD}
|
||||
# Server / general settings
|
||||
- GITEA__server__DOMAIN=${GITEA_DOMAIN}
|
||||
- GITEA__server__ROOT_URL=${GITEA_ROOT_URL}
|
||||
- GITEA__server__SSH_DOMAIN=${GITEA_DOMAIN}
|
||||
- GITEA__server__SSH_PORT=${GITEA_SSH_HOST_PORT}
|
||||
# Security secrets (generate these — see notes)
|
||||
- GITEA__security__SECRET_KEY=${GITEA_SECRET_KEY}
|
||||
- GITEA__security__INTERNAL_TOKEN=${GITEA_INTERNAL_TOKEN}
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- ./gitea:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "${GITEA_HTTP_HOST_PORT}:3000"
|
||||
- "${GITEA_SSH_HOST_PORT}:22"
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
db:
|
||||
image: docker.io/library/postgres:14
|
||||
container_name: gitea-db
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- ./postgres:/var/lib/postgresql/data
|
||||
Reference in New Issue
Block a user