Compare commits

...

2 Commits

Author SHA1 Message Date
fdc40a91e1 Added examples folder 2023-01-24 14:49:25 +01:00
695371f600 Added environment variables to .env and docker-compose.yml 2023-01-24 14:47:50 +01:00
3 changed files with 147 additions and 5 deletions

17
.env
View File

@@ -2,8 +2,21 @@
GITEA_UID=106
GITEA_GID=113
GITEA_NAME='MyGitRepo'
GITEA__server__DOMAIN='gitea.example.com'
GITEA__server__ROOT_URL='https://gitea.example.com'
GITEA__mailer__ENABLED='true'
GITEA__mailer__PROTOCOL='smtp'
GITEA__mailer__SMTP_ADDR='mail.example.com'
GITEA__mailer__SMTP_PORT='25'
GITEA__mailer__FROM='noreply@example.com'
GITEA__mailer__USER='user@example.com'
GITEA__mailer__PASSWD='secret'
# DB
POSTGRES_PASSWORD='Dn32ps$EmcGsw'
POSTGRES_PASSWORD='$$$changeMe$$$$'
POSTGRES_DB=gitea
POSTGRES_USER=gitea

View File

@@ -1,4 +1,4 @@
version: "3"
version: "3.8"
services:
@@ -16,15 +16,29 @@ services:
gitea:
image: gitea/gitea:latest
# container_name: gitea
container_name: gitea
environment:
- APP_NAME=${GITEA_NAME}
- USER_UID=${GITEA_UID}
- USER_GID=${GITEA_GID}
- GITEA__server__ROOT_URL=${GITEA__server__ROOT_URL:?GITEA__server__ROOT_URL not set}
- GITEA__server__DOMAIN=${GITEA__server__DOMAIN:?GITEA__server__DOMAIN not set}
- GITEA__service__DISABLE_REGISTRATION=true
### IF Mailer is used you can activate self registration with email confirmation, mail notifies...
- GITEA__service__REGISTER_EMAIL_CONFIRM=true
- GITEA__service__ENABLE_NOTIFY_MAIL=true
- 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}
- GITEA__mailer__ENABLED=${GITEA__mailer__ENABLED:?GITEA__mailer__ENABLED not set}
- GITEA__mailer__SMTP_ADDR=${GITEA__mailer__SMTP_ADDR:?GITEA__mailer__SMTP_ADDR not set}
- GITEA__mailer__SMTP_PORT=${GITEA__mailer__SMTP_PORT:?GITEA__mailer__SMTP_PORT not set}
- GITEA__mailer__PROTOCOL=${GITEA__mailer__PROTOCOL:?GITEA__mailer__PROTOCOL not set}
- GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set}
# - GITEA__mailer__USER=${GITEA__mailer__USER:?GITEA__mailer__USER not set}
# - GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}"""
restart: always
networks:
- default
@@ -41,12 +55,17 @@ services:
labels:
- traefik.enable=true
- traefik.http.routers.gitea.rule=Host(`gitea.cthsg.de`)
- traefik.http.routers.gitea.rule=Host(`gitea.example.com`)
- traefik.http.routers.gitea.tls.certResolver=le
- traefik.http.routers.gitea.service=gitea
- traefik.http.services.gitea.loadbalancer.server.port=3000
- traefik.docker.network=proxy
logging:
driver: "json-file"
options:
max-size: "1m"
networks:
proxy:
external: true

View File

@@ -0,0 +1,110 @@
# Source: https://containers.fan/posts/setup-gitea-on-docker-with-traefik/
---
version: '3.8'
services:
gitea-traefik:
image: traefik:2.4
container_name: gitea-traefik
restart: unless-stopped
volumes:
- ./traefik/acme.json:/acme.json
- /var/run/docker.sock:/var/run/docker.sock
networks:
- public
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.api.rule=Host(`traefik.rbkr.xyz`)'
- 'traefik.http.routers.api.entrypoints=https'
- 'traefik.http.routers.api.service=api@internal'
- 'traefik.http.routers.api.tls=true'
- 'traefik.http.routers.api.tls.certresolver=letsencrypt'
ports:
- 80:80
- 443:443
command:
- '--api'
- '--providers.docker=true'
- '--providers.docker.exposedByDefault=false'
- '--entrypoints.http=true'
- '--entrypoints.http.address=:80'
- '--entrypoints.http.http.redirections.entrypoint.to=https'
- '--entrypoints.http.http.redirections.entrypoint.scheme=https'
- '--entrypoints.https=true'
- '--entrypoints.https.address=:443'
- '--certificatesResolvers.letsencrypt.acme.email=me@example.com'
- '--certificatesResolvers.letsencrypt.acme.storage=acme.json'
- '--certificatesResolvers.letsencrypt.acme.httpChallenge.entryPoint=http'
- '--log=true'
- '--log.level=INFO'
logging:
driver: "json-file"
options:
max-size: "1m"
gitea:
container_name: gitea
image: gitea/gitea:${GITEA_VERSION:-1.14.5}
restart: unless-stopped
depends_on:
gitea-traefik:
condition: service_started
gitea-cache:
condition: service_healthy
environment:
- APP_NAME="Gitea"
- USER_UID=1000
- USER_GID=1000
- USER=git
- RUN_MODE=prod
- DOMAIN=git.rbkr.xyz
- SSH_DOMAIN=git.rbkr.xyz
- HTTP_PORT=3000
- ROOT_URL=https://git.rbkr.xyz
- SSH_PORT=222
- SSH_LISTEN_PORT=22
- DB_TYPE=sqlite3
- GITEA__cache__ENABLED=true
- GITEA__cache__ADAPTER=redis
- GITEA__cache__HOST=redis://gitea-cache:6379/0?pool_size=100&idle_timeout=180s
- GITEA__cache__ITEM_TTL=24h
ports:
- "222:22"
networks:
- public
volumes:
- ./data/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitea.rule=Host(`git.rbkr.xyz`)"
- "traefik.http.routers.gitea.entrypoints=https"
- "traefik.http.routers.gitea.tls.certresolver=letsencrypt"
- "traefik.http.routers.gitea.service=gitea-service"
- "traefik.http.services.gitea-service.loadbalancer.server.port=3000"
logging:
driver: "json-file"
options:
max-size: "1m"
gitea-cache:
container_name: gitea-cache
image: redis:6-alpine
restart: unless-stopped
networks:
- public
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 15s
timeout: 3s
retries: 30
logging:
driver: "json-file"
options:
max-size: "1m"
networks:
public:
name: public