Skip to content

Instantly share code, notes, and snippets.

@MarshalX
Last active June 15, 2023 07:34
Show Gist options
  • Save MarshalX/dafbcfcff75831626f986d99072409cf to your computer and use it in GitHub Desktop.
Save MarshalX/dafbcfcff75831626f986d99072409cf to your computer and use it in GitHub Desktop.
Gitea with mirroring of all GitHub repositories (public & private)
# Fill/change env vars, run docker compose up, setup reverse proxy; complete installation process on first site visit
version: "3"
networks:
gitea:
external: false
volumes:
gitea:
driver: local
postgres:
driver: local
services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
# database
- GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=db:5432
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
# app.ini
- GITEA__api__ENABLE_SWAGGER=false
- GITEA__packages__ENABLED=false
- GITEA__server__DISABLE_SSH=true
- GITEA__security__DISABLE_WEBHOOKS=true
- GITEA__migrations__ALLOWED_DOMAINS=github.com,*.github.com
- GITEA__repository__DISABLED_REPO_UNITS=repo.issues, repo.ext_issues, repo.pulls, repo.wiki, repo.ext_wiki, repo.projects
- GITEA__service__DISABLE_REGISTRATION=true
- GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION=false
- GITEA__service__DEFAULT_USER_IS_RESTRICTED=true
- GITEA__attachment__ENABLED=false
# more options: https://docs.gitea.com/next/administration/config-cheat-sheet#service-service
restart: always
networks:
- gitea
volumes:
- gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: postgres:14
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- postgres:/var/lib/postgresql/data
mirror-to-gitea: # run after gitea installation
image: jaedle/mirror-to-gitea:latest
restart: always
environment:
- GITHUB_USERNAME=username
- GITEA_URL=https://yourdomain.your
- GITEA_TOKEN=token # token scopes: write:repository, read:user
- GITHUB_TOKEN=token # token scopes: repo
- MIRROR_PRIVATE_REPOSITORIES=true
- DELAY=3600 # in seconds
container_name: mirror-to-gitea
# ref: https://docs.gitea.com/administration/reverse-proxies#nginx
server {
listen 80;
server_name git.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment