Environment Variables
This is the full reference. Most of these variables have an equivalent control in the web interface, and for a typical deployment you only need the handful in Core and Authentication and secrets. See Configuration for how the two layers relate.
How environment configuration is applied
Variables fall into two groups.
Process variables are read directly by the running server: the host, port, base path, secrets, and auth URLs. They take effect immediately and have no UI equivalent.
Seeded variables are copied into the database. On startup, if any of GITHUB_USERNAME, GITHUB_TOKEN, GITEA_URL, GITEA_USERNAME, or GITEA_TOKEN is set, Gitea Mirror parses the whole environment configuration and writes it to the first user’s configuration row. If no user account exists yet, nothing is written and it tries again on the next start.
Warning: A seeded variable that is set is written again on every startup, so it wins over changes you make in the UI. A variable you leave unset (or empty) is not written, and the value saved on the Configuration page stays. Manage a given setting either through the environment or through the UI, not both.
docker-compose.ymlsets most of these variables with a default, so with that file they are always set: remove a line to manage that setting in the UI.
Note: A true/false variable is true when set to
true(in any case) and false for any other value.AUTO_IMPORT_REPOSis the reverse: onlyfalseturns it off. The defaults listed below apply on a first start, when nothing is stored yet.
Core
| Variable | Default | Description |
|---|---|---|
NODE_ENV |
development |
Runtime environment. The container image sets production. |
HOST |
0.0.0.0 |
Interface to bind. The development server (bun run dev) binds localhost instead. |
PORT |
4321 |
Port to listen on. In Docker, keep it at 4321 and map a different host port instead: the image’s health check always probes 4321. |
BASE_URL |
/ |
Path prefix for subpath deployments, for example /mirror. Applied at runtime, so one prebuilt image works under any prefix. |
MCP_INTERNAL_URL |
http://HOST:PORT plus BASE_URL |
Address the MCP endpoint tools use to call the app’s own API. Only needed when the app is not reachable from itself at HOST and PORT, for example when it terminates TLS itself. |
DATABASE_URL |
sqlite://data/gitea-mirror.db |
SQLite database location. The container image sets file:data/gitea-mirror.db. |
Note:
DATABASE_URLaccepts thesqlite://scheme, the legacyfile:scheme, or a plain path. Relative paths resolve against the process working directory and the parent directory is created if it is missing. Point it at a mounted volume to relocate the database. gitea-mirror only supports SQLite, so any other scheme, such aspostgresql://, is ignored with a warning and the default location is used.
Authentication and secrets
| Variable | Default | Description |
|---|---|---|
BETTER_AUTH_SECRET |
none | Signs session cookies. Required, except with the Docker image and the Nix package, which generate one on first start. Generate with openssl rand -base64 32. |
BETTER_AUTH_URL |
http://localhost:4321 |
Origin the auth server runs on. Scheme and host only, any path is stripped. |
PUBLIC_BETTER_AUTH_URL |
none | Leave it unset. It is only read while building from source, and the value is fixed into that build. The published image and the Nix package are built without it, so the browser sends sign-in requests to whatever address it opened the page on, and setting it on a running container changes nothing. |
BETTER_AUTH_TRUSTED_ORIGINS |
none | Comma-separated additional origins allowed to make auth requests. The origin of BETTER_AUTH_URL is always trusted. |
BETTER_AUTH_LOG_LEVEL |
warn |
Better Auth logger verbosity: debug, info, warn, or error. Use debug to trace SSO and OIDC sign-in problems. Better Auth does not read the DEBUG variable. |
ENCRYPTION_SECRET |
none | Key for AES-256-GCM encryption of stored tokens. When unset, BETTER_AUTH_SECRET is used. Changing the key later makes stored tokens unreadable, so set it before saving any. Generate with openssl rand -base64 48. |
AUTH_DEFAULT_METHOD |
email |
Tab the login page opens on when both email and SSO are available: email or sso. Any other value means email. The method last used in that browser wins over this default. |
AUTH_ALLOW_SIGNUP |
false |
Allow new accounts after the first one exists. On, the email and password sign-up endpoint (POST /api/auth/sign-up/email) stays open and SSO creates an account for any email. Off, the endpoint answers 403 once a user exists and SSO only creates accounts for emails in the provider’s Domain. The /signup page redirects to the login page either way. |
In Docker, BETTER_AUTH_SECRET and ENCRYPTION_SECRET are generated on first boot if unset and saved to /app/data/.better_auth_secret and /app/data/.encryption_secret so they persist across restarts. The Nix package does the same in its data directory. Elsewhere there is no fallback: without BETTER_AUTH_SECRET the app refuses to start when NODE_ENV is production, and uses a known insecure value otherwise.
Header authentication
For deployments behind a reverse proxy that already authenticates users.
| Variable | Default | Description |
|---|---|---|
HEADER_AUTH_ENABLED |
false |
Enable header-based authentication. |
HEADER_AUTH_USER_HEADER |
X-Authentik-Username |
Request header carrying the username. |
HEADER_AUTH_EMAIL_HEADER |
X-Authentik-Email |
Request header carrying the email address. |
HEADER_AUTH_NAME_HEADER |
X-Authentik-Name |
Request header carrying the display name. |
HEADER_AUTH_AUTO_PROVISION |
false |
Create accounts automatically for unrecognized users. |
HEADER_AUTH_ALLOWED_DOMAINS |
none | Comma-separated email domains allowed to sign in through headers, for existing users as well as new ones. Only checked when the email header is present. |
Warning: Enable this only when a trusted proxy strips these headers from inbound client requests. Otherwise any client can set them and sign in as any user.
Source
Connection
The variable names are historical: GITHUB_USERNAME and GITHUB_TOKEN hold the credentials for whichever source is selected. See Sources.
| Variable | Default | Description |
|---|---|---|
SOURCE_PROVIDER |
github |
Which host repositories are pulled from: github, gitlab, gitea or git. gitea also covers Forgejo and Codeberg, and git is a plain git host. Anything other than github is beta. |
SOURCE_URL |
https://gitlab.com or https://codeberg.org |
Base URL of the GitLab or Gitea / Forgejo instance. Ignored for GitHub, which uses GH_API_URL. |
GITLAB_PAGE_SIZE |
100 |
How many projects a GitLab listing asks for at a time, from 10 to 100. Gitea Mirror starts at 100 and drops to 50, 20, then 10 when a page times out, which costs about 30 s per step on every import. Set a lower value for a slow GitLab so it starts there; it still steps down below it. |
GITHUB_USERNAME |
none | Your username on the source host. |
GITHUB_TOKEN |
none | Personal access token for the source host. GitHub needs repo and read:org, GitLab read_api and read_repository, Gitea / Forgejo read:repository, read:user and read:organization. |
GH_API_URL |
https://api.github.com |
GitHub API base URL. Point this at GitHub Enterprise Server (https://ghe.example.com/api/v3) or Enterprise Cloud with data residency (https://api.TENANT.ghe.com). |
GITHUB_API_URL |
none | Alternate name for GH_API_URL, checked second. Prefer GH_API_URL, since GITHUB_API_URL is set automatically inside GitHub Actions and can collide. |
Standard GitHub Enterprise Cloud on github.com needs no override. Use a token issued by the target Enterprise instance.
Repository selection
| Variable | Default | Description |
|---|---|---|
PRIVATE_REPOSITORIES |
false |
Include private repositories. |
PUBLIC_REPOSITORIES |
true |
Include public repositories. |
INCLUDE_ARCHIVED |
false |
Include archived repositories. |
INCLUDE_COLLABORATOR_REPOS |
true |
Include repositories where you are a collaborator rather than the owner. Set to false to limit imports to repositories you own. |
SKIP_FORKS |
false |
Skip forked repositories. |
MIRROR_STARRED |
false |
Mirror repositories you have starred. |
MIRROR_STARRED_LISTS |
none | Comma-separated GitHub Star List names to restrict starred mirroring to. Only used when MIRROR_STARRED=true. Empty means all starred repositories. |
STARRED_REPOS_ORG |
starred |
Gitea organization that receives starred repositories. |
STARRED_REPOS_MODE |
dedicated-org |
dedicated-org puts starred repositories in one organization, preserve-owner keeps the original owner path. |
STARRED_DUPLICATE_STRATEGY |
suffix |
Name collision handling when two starred repositories share a name. suffix gives repo-owner, prefix gives owner-repo, owner-org is accepted but not implemented yet and behaves like suffix. |
SKIP_STARRED_ISSUES |
false |
Lightweight mode for starred repositories: mirror code and LFS, but skip the wiki, releases, issues, pull requests, labels and milestones. |
AUTO_MIRROR_STARRED |
false |
Mirror starred repositories during scheduled syncs and “Mirror All”. When false, they are imported for browsing but must be mirrored individually. |
Organizations
| Variable | Default | Description |
|---|---|---|
MIRROR_ORGANIZATIONS |
false |
Mirror repositories owned by GitHub organizations. |
INCLUDE_ORGANIZATIONS |
none | Comma-separated allowlist. When set, only these organizations are mirrored. Empty means all organizations you belong to. |
GITHUB_EXCLUDED_ORGS |
none | Comma-separated denylist. These organizations are skipped during discovery, matched case-insensitively. |
ONLY_MIRROR_ORGS |
false |
Skip your personal repositories and mirror only organization repositories. |
PRESERVE_ORG_STRUCTURE |
false |
Keep the GitHub organization structure in Gitea. Shorthand for the preserve strategy. |
MIRROR_STRATEGY |
preserve |
Destination layout: preserve, single-org, flat-user, or mixed. Takes precedence over PRESERVE_ORG_STRUCTURE. |
Destination
Connection
The GITEA_* names are kept for every destination kind, so an existing deployment only has to add DESTINATION_PROVIDER. See Destinations.
| Variable | Default | Description |
|---|---|---|
DESTINATION_PROVIDER |
gitea |
Which host mirrors are created on: gitea, forgejo, github or gitlab. Gitea and Forgejo are pull mirrors; GitHub and GitLab receive pushes of branches and tags from the app. Anything other than gitea is beta. |
GITEA_URL |
none | Destination instance URL used for all API and mirroring traffic. Optional for GitHub and GitLab, which default to github.com and gitlab.com; set it for GitHub Enterprise Server or a self-hosted GitLab. |
GITEA_EXTERNAL_URL |
none | Browser-facing URL used for dashboard links, when it differs from GITEA_URL. |
GITEA_TOKEN |
none | Destination access token. GitHub push targets need repo and workflow, plus delete_repo if cleanup should delete; GitLab needs api and write_repository. |
GITEA_USERNAME |
none | Destination username, used as the default owner. |
GITEA_ORGANIZATION |
github-mirrors |
Default destination organization or group for the single-org strategy. |
GITEA_SKIP_TLS_VERIFY |
false |
Docker image only: disable TLS certificate verification. The entrypoint sets NODE_TLS_REJECT_UNAUTHORIZED=0 process-wide. Elsewhere, set NODE_TLS_REJECT_UNAUTHORIZED=0 yourself. |
Push engine
Only used when DESTINATION_PROVIDER is github or gitlab.
| Variable | Default | Description |
|---|---|---|
MIRROR_CLONE_DIR |
mirrors next to the database file |
Where the push engine keeps its bare clones, one per repository. The default follows DATABASE_URL. |
PUSH_CONCURRENCY |
2 |
How many git fetch or push operations run at once across all repositories, 1 to 32. |
Warning:
GITEA_SKIP_TLS_VERIFY=truedisables certificate checking for every outbound HTTPS request the process makes, not just to Gitea. Use CA certificates instead for self-signed or privately signed instances.
Repository settings
| Variable | Default | Description |
|---|---|---|
GITEA_ORG_VISIBILITY |
public |
Visibility for organizations Gitea Mirror creates: public, private, limited, or default. |
GITEA_MIRROR_INTERVAL |
8h |
How often Gitea itself re-pulls each mirror. Setting this also enables the scheduler. Gitea reads it as a Go duration, so use hours and minutes (30m, 8h, 24h, 168h for a week); days (1d) and plain numbers are refused. It cannot be lower than the destination’s [mirror] MIN_INTERVAL (10 minutes by default). |
GITEA_LFS |
false |
Mirror Git LFS objects. Requires LFS enabled on the Gitea server. |
GITEA_PRESERVE_VISIBILITY |
false |
GitHub and GitLab destinations only: give each pushed repository the source repository’s visibility. Gitea and Forgejo mirrors follow the source’s visibility already. |
GITEA_ADD_TOPICS |
true |
Copy repository topics to the mirror. |
GITEA_TOPIC_PREFIX |
none | Prefix applied to copied topics. |
Mirror content
| Variable | Default | Description |
|---|---|---|
MIRROR_METADATA |
false |
The metadata switch on the Configuration page. Turning on any of the four options below turns it on too. Through the environment it does not switch those four off: set them to false instead. |
MIRROR_ISSUES |
false |
Mirror issues with their comments and labels. |
MIRROR_PULL_REQUESTS |
false |
Mirror pull requests. Gitea’s API cannot create pull requests, so they are created as issues tagged with a pull-request label. |
MIRROR_LABELS |
false |
Mirror repository labels. |
MIRROR_MILESTONES |
false |
Mirror milestones. |
MIRROR_RELEASES |
false |
Mirror GitHub releases along with their assets. |
RELEASE_LIMIT |
10 |
Maximum releases mirrored per repository, newest first. |
RELEASE_TYPE |
all |
Which releases are candidates: all or stable (skip what the source marks as a pre-release). With a filter active the limit counts the releases that match, and releases of the other kind are removed from Gitea on the next sync. |
RELEASE_INCLUDE_TAGS |
empty | Comma separated tag patterns; only releases whose tag matches are mirrored. A pattern is a glob over the whole tag (v1.*, *-rc.*) or a regular expression in slashes (/^v\d+\.\d+\.\d+$/), matched case-insensitively. |
RELEASE_EXCLUDE_TAGS |
empty | Comma separated tag patterns in the same syntax; matching releases are skipped, and an excluded tag wins over RELEASE_INCLUDE_TAGS. |
RELEASE_ASSET_LIMIT |
unset | Upload release assets only for the newest N mirrored releases; older releases still get their notes and tag. Unset means assets for every mirrored release, 0 means notes only. Lowering it never deletes assets already uploaded unless PRUNE_OLD_RELEASE_ASSETS is on. |
PRUNE_OLD_RELEASE_ASSETS |
false |
Opt-in cleanup for what the asset limit left behind. On, every sync also deletes the attachments of each mirrored release ranked past RELEASE_ASSET_LIMIT; the releases and their notes stay. |
MIRROR_WIKI |
false |
Clone wiki content. |
MIRROR_ISSUE_CONCURRENCY |
3 |
Issues processed in parallel. |
MIRROR_PULL_REQUEST_CONCURRENCY |
5 |
Pull requests processed in parallel. |
Note: Concurrency above
1speeds up metadata mirroring but issues and pull requests may be created out of chronological order, since Gitea assigns numbers on creation. Set both to1if exact ordering matters more than throughput.
Issues, pull requests, labels and milestones are read from the GitHub API and need a GitHub source. Releases are read from the source’s own API, so they mirror from GitHub and from Gitea/Forgejo sources, but not from GitLab. With a GitHub or GitLab destination none of the metadata options apply, and neither do wiki and LFS: push targets receive branches and tags only.
Scheduling
| Variable | Default | Description |
|---|---|---|
SCHEDULE_ENABLED |
false |
Enable automatic mirroring. Also enabled implicitly whenever SCHEDULE_INTERVAL, GITEA_MIRROR_INTERVAL, or DELAY is set. |
SCHEDULE_INTERVAL |
3600 |
Interval between syncs. Accepts a duration string (30m, 8h, 7d), a five-field cron expression (0 2 * * *), or a plain number of seconds. |
DELAY |
none | Legacy alias for SCHEDULE_INTERVAL, in seconds. SCHEDULE_INTERVAL takes precedence. |
SCHEDULE_TIMEZONE |
UTC |
Timezone used to evaluate cron expressions. |
SCHEDULE_CONCURRENT |
false |
Sync the repositories within one batch at the same time instead of one after another. |
SCHEDULE_BATCH_SIZE |
10 |
Repositories processed per batch. |
SCHEDULE_PAUSE_BETWEEN_BATCHES |
5000 |
Pause between batches, in milliseconds. |
Discovery and update detection
| Variable | Default | Description |
|---|---|---|
AUTO_IMPORT_REPOS |
true |
Discover and import newly created repositories on the source during scheduled syncs. Set to false to disable. |
AUTO_MIRROR_REPOS |
false |
Mirror newly imported repositories automatically, without a manual “Mirror All”. |
SCHEDULE_ONLY_MIRROR_UPDATED |
false |
Skip repositories mirrored within the last SCHEDULE_UPDATE_INTERVAL. It does not check the source for changes. |
SCHEDULE_UPDATE_INTERVAL |
86400000 |
With SCHEDULE_ONLY_MIRROR_UPDATED, how recently a repository must have been mirrored to be skipped, in milliseconds. |
SCHEDULE_SKIP_RECENTLY_MIRRORED |
true |
Skip repositories mirrored very recently. |
SCHEDULE_RECENT_THRESHOLD |
3600000 |
What counts as recent, in milliseconds. |
Notifications
Notification providers themselves (ntfy, Apprise, Gotify, and generic webhook) are configured on the Notifications tab of the Configuration page, not through environment variables.
Cleanup
Cleanup covers both trimming the activity log and handling repositories that no longer exist on the source. See Cleanup and reconcile.
| Variable | Default | Description |
|---|---|---|
CLEANUP_ENABLED |
false |
Trim the activity log on a schedule. Repositories gone from the source are only handled when CLEANUP_DELETE_IF_NOT_IN_GITHUB is on, which also turns this on. |
CLEANUP_RETENTION_DAYS |
7 |
How long activity events are kept, in days. |
CLEANUP_DELETE_IF_NOT_IN_GITHUB |
true |
Act on repositories that no longer exist on the source. |
CLEANUP_ORPHANED_REPO_ACTION |
archive |
What to do with an orphaned repository: skip, archive, or delete. |
CLEANUP_DELETE_FROM_GITEA |
false |
Apply the orphan action on the destination too, not just in the local database. Deleting on a GitHub push target needs the delete_repo scope. |
CLEANUP_PROTECTED_REPOS |
none | Comma-separated repositories cleanup will never touch, matched exactly by name or by owner/name. |
CLEANUP_DRY_RUN |
false |
Log what cleanup would do without doing it. |
CLEANUP_BATCH_SIZE |
10 |
Items processed per batch. |
CLEANUP_PAUSE_BETWEEN_DELETES |
2000 |
Pause between deletions, in milliseconds. |
Cleanup has several safety behaviors worth knowing:
- If the source API returns an error, cleanup is skipped for that run. A rate limit or a failed direct lookup never causes a mirror to be treated as orphaned; only a clean 404 on the repository itself does.
- The
archiveaction never deletes. Regular repositories use Gitea’s native archive flag, which makes them read-only while preserving all data. Mirror repositories cannot be archived through the Gitea API, so they are renamed with anarchived-prefix, given a description noting the preservation, and have automatic syncing turned off. They remain fully cloneable, and you can still sync them by hand from the Repositories page. - If archiving fails for any reason, the repository is left alone and stays accessible.
Force-push protection
These set the starting values for force-push protection, which is normally configured in the UI.
| Variable | Default | Description |
|---|---|---|
PRE_SYNC_BACKUP_STRATEGY |
unset | Initial strategy: disabled, always, on-force-push or block-on-force-push. |
PRE_SYNC_BACKUP_ENABLED |
unset | Legacy switch. true maps to always, false to disabled. |
PRE_SYNC_BACKUP_DIR |
data/repo-backups |
Starting snapshot directory. |
PRE_SYNC_BACKUP_KEEP_COUNT |
5 |
Starting retention count. |
PRE_SYNC_BACKUP_RETENTION_DAYS |
30 |
Starting retention days. |
PRE_SYNC_BACKUP_GIT_USERNAME |
oauth2 |
Username paired with the Gitea token when cloning for a snapshot. |
TLS
| Variable | Default | Description |
|---|---|---|
NODE_EXTRA_CA_CERTS |
none | Path to a PEM certificate or bundle to add to the trusted CA set. See CA certificates. |
SERVER_CERT_PATH |
none | Path to a TLS certificate for direct HTTPS. |
SERVER_KEY_PATH |
none | Path to the matching private key. |
Warning:
SERVER_CERT_PATHandSERVER_KEY_PATHare read by the Astro Node standalone adapter, which only runs when you launchdist/server/entry.mjsdirectly. The default startup path, used bybun run startand by the Docker image, runsscripts/runtime-server.tsinstead, which serves plain HTTP so it can applyBASE_URLpath rewriting. In those setups these two variables have no effect and you should terminate TLS at a reverse proxy.
Docker Compose substitution
These are not read by the application. They are substituted into the repository’s docker-compose.yml when it resolves which image to pull or build.
| Variable | Default | Description |
|---|---|---|
DOCKER_REGISTRY |
ghcr.io |
Registry hostname. |
DOCKER_IMAGE |
raylabshq/gitea-mirror |
Image repository. |
DOCKER_TAG |
latest |
Image tag. |
PUID |
1000 |
User ID the container runs as. Used by docker-compose.alt.yml. |
PGID |
1000 |
Group ID the container runs as. Used by docker-compose.alt.yml. |
