Files
gitea-mirror/docker-compose.dev.yml
T
ARUNAVO RAY 25a1ce059d chore(docker): drop all capabilities and set no-new-privileges in compose (#545)
* docs(deployment): note that the image works with all capabilities dropped

The app runs as a regular user with no capabilities in effect, and the
image has no setuid programs, so cap_drop ALL and no-new-privileges change
nothing day to day. Tested on v3.55.0 with the default user and with
user: 1000:1000 and a bind mount. Document that they work, for setups that
require them, instead of adding them to the default compose files.

Refs #544

* chore(docker): drop all capabilities and set no-new-privileges in compose

The app runs as a regular user with no capabilities in effect, so this
changes nothing day to day and limits what someone who broke into the
container could do. Added to the three compose files and the compose and
docker run examples in the docs, with a note for anyone running the
container as root.

Suggested by @zwimer in #544.
2026-11-24 13:22:40 +05:30

125 lines
4.3 KiB
YAML

# Development environment with local Gitea instance for testing
# Run with: docker compose -f docker-compose.dev.yml up -d
services:
# Local Gitea instance for testing
gitea:
image: gitea/gitea:latest
container_name: gitea
restart: unless-stopped
entrypoint: ["/tmp/gitea-dev-init.sh"]
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=sqlite3
- GITEA__database__PATH=/data/gitea/gitea.db
- GITEA__server__DOMAIN=localhost
- GITEA__server__ROOT_URL=http://localhost:3001/
- GITEA__server__SSH_DOMAIN=localhost
- GITEA__server__SSH_PORT=2222
- GITEA__server__START_SSH_SERVER=true
- GITEA__security__INSTALL_LOCK=true
- GITEA__service__DISABLE_REGISTRATION=false
- GITEA__log__MODE=console
- GITEA__log__LEVEL=Info
ports:
- "3001:3000"
- "2222:22"
volumes:
- gitea-data:/data
- gitea-config:/etc/gitea
- ./scripts/gitea-app.ini:/tmp/app.ini:ro
- ./scripts/gitea-dev-init.sh:/tmp/gitea-dev-init.sh:ro
networks:
- gitea-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
# Development service connected to local Gitea
gitea-mirror-dev:
# For dev environment, always build from local sources
build:
context: .
dockerfile: Dockerfile
platforms:
- linux/amd64
- linux/arm64
container_name: gitea-mirror-dev
restart: unless-stopped
# The app runs as a regular user and needs no Linux capabilities
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
ports:
- "4321:4321"
volumes:
- gitea-mirror-data:/app/data
# Mount custom CA certificates - choose one option:
# Option 1: Mount individual CA certificates from certs directory
# - ./certs:/app/certs # must be writable: the entrypoint writes ca-bundle.crt here
# Option 2: Mount system CA bundle (if your CA is already in system store)
# - /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro
depends_on:
- gitea
environment:
- NODE_ENV=development
- DATABASE_URL=file:data/gitea-mirror.db
- HOST=0.0.0.0
- PORT=4321
- BASE_URL=${BASE_URL:-/}
- BETTER_AUTH_SECRET=dev-secret-key
# GitHub/Gitea Mirror Config
- GITHUB_USERNAME=${GITHUB_USERNAME:-your-github-username}
- GITHUB_TOKEN=${GITHUB_TOKEN:-your-github-token}
- GITHUB_EXCLUDED_ORGS=${GITHUB_EXCLUDED_ORGS:-}
- SKIP_FORKS=${SKIP_FORKS:-false}
- PRIVATE_REPOSITORIES=${PRIVATE_REPOSITORIES:-false}
- MIRROR_ISSUES=${MIRROR_ISSUES:-false}
- MIRROR_WIKI=${MIRROR_WIKI:-false}
- MIRROR_STARRED=${MIRROR_STARRED:-false}
- MIRROR_ORGANIZATIONS=${MIRROR_ORGANIZATIONS:-false}
- PRESERVE_ORG_STRUCTURE=${PRESERVE_ORG_STRUCTURE:-false}
- ONLY_MIRROR_ORGS=${ONLY_MIRROR_ORGS:-false}
- SKIP_STARRED_ISSUES=${SKIP_STARRED_ISSUES:-false}
- GITEA_URL=http://gitea:3000
- GITEA_TOKEN=${GITEA_TOKEN:-your-local-gitea-token}
- GITEA_USERNAME=${GITEA_USERNAME:-your-local-gitea-username}
- GITEA_ORGANIZATION=${GITEA_ORGANIZATION:-github-mirrors}
- GITEA_ORG_VISIBILITY=${GITEA_ORG_VISIBILITY:-public}
- DELAY=${DELAY:-3600}
# Optional: Skip TLS verification (insecure, use only for testing)
# - GITEA_SKIP_TLS_VERIFY=${GITEA_SKIP_TLS_VERIFY:-false}
healthcheck:
test:
[
"CMD-SHELL",
"BASE=\"${BASE_URL:-/}\"; if [ \"$${BASE}\" = \"/\" ]; then BASE=\"\"; else BASE=\"$${BASE%/}\"; fi; wget --no-verbose --tries=1 --spider \"http://localhost:4321$${BASE}/api/health\"",
]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s
networks:
- gitea-network
# Define named volumes for data persistence
volumes:
gitea-data: # Gitea data volume
gitea-config: # Gitea config volume
gitea-mirror-data: # Gitea Mirror database volume
# Define networks
networks:
gitea-network:
name: gitea-network
# Let Docker Compose manage this network
# If you need to use an existing network, uncomment the line below
# external: true