From 0a6ffbf67dce75e773f9222063573a5ac1e91d35 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Fri, 23 Apr 2021 16:32:54 +0200 Subject: [PATCH] Added initial gitea config --- gitea/.env.example | 16 ++++++ gitea/docker-compose.yml | 59 +++++++++++++++++++++++ nginx/.env.example | 20 +++++--- nginx/sites-available/gitea.conf.template | 23 +++++++++ 4 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 gitea/.env.example create mode 100644 gitea/docker-compose.yml create mode 100644 nginx/sites-available/gitea.conf.template diff --git a/gitea/.env.example b/gitea/.env.example new file mode 100644 index 0000000..95e1324 --- /dev/null +++ b/gitea/.env.example @@ -0,0 +1,16 @@ +# User to run container as +USER_UID=1000 +USER_GID=1000 + +# Database settings +DB_TYPE=postgres +DB_HOST=db:5432 +DB_NAME=gitea +DB_USER=gitea +DB_PASSWD=gitea + +# Wether to start LFS +LFS_START_SERVER=true + +# Wether to allow registration +DISABLE_REGISTRATION=true diff --git a/gitea/docker-compose.yml b/gitea/docker-compose.yml new file mode 100644 index 0000000..6e65af8 --- /dev/null +++ b/gitea/docker-compose.yml @@ -0,0 +1,59 @@ +version: '2.4' + +services: + app: + # Latest contains a development version + image: 'gitea/gitea:1.14.1-rootless' + restart: 'always' + + depends_on: + db: + condition: 'service_healthy' + healthcheck: + test: 'curl -f localhost:3000 || exit 1' + interval: '30s' + timeout: '5s' + retries: 3 + start_period: '5s' + + env_file: + - '.env' + networks: + - 'default' + - 'nginx' + ports: + - '22:22' + volumes: + - 'data:/data' + - 'repos:/data/git/repositories' + - 'lfs:/data/git/lfs' + - '/etc/timezone:/etc/timezone:ro' + - '/etc/localtime:/etc/localtime:ro' + + db: + image: 'postgres:13.2-alpine' + restart: 'always' + + healthcheck: + test: 'pg_isready -U gitea' + interval: '30s' + timeout: '5s' + retries: 3 + start_period: '0s' + + environment: + - 'POSTGRES_USER=gitea' + - 'POSTGRES_PASSWORD=gitea' + - 'POSTGRES_DB=gitea' + volumes: + - 'db-data:/var/lib/postgresql/data' + +networks: + nginx: + external: true + +volumes: + data: + lfs: + db-data: + repos: diff --git a/nginx/.env.example b/nginx/.env.example index 78f88a3..39f272a 100644 --- a/nginx/.env.example +++ b/nginx/.env.example @@ -14,40 +14,46 @@ HTTPS_PORT=443 # =====PER-SERVICE CONFIGURATION===== # Domain name: domain name that points to the instance -# Host name: basically the argument to proxy_pass +# Hostname: basically the argument to proxy_pass ## Firefly III ### Domain name FIREFLY_DOMAIN= -### Host name +### Hostname FIREFLY_HOST=firefly_app_1 ## Koel ### Domain name KOEL_DOMAIN= -### Host name +### Hostname KOEL_HOST=koel_app_1 ## Miniflux ### Domain name MINIFLUX_DOMAIN= -### Host name +### Hostname MINIFLUX_HOST=miniflux_app_1 ## Monica ### Domain name MONICA_DOMAIN= -### Host name +### Hostname MONICA_HOST=monica_app_1 ## Nextcloud ### Domain name NEXTCLOUD_DOMAIN= -### Host name +### Hostname NEXTCLOUD_HOST=nextcloud_app_1 ## Portainer ### Domain name PORTAINER_DOMAIN= -### Host name +### Hostname PORTAINER_HOST=portainer_app_1 + +## Gitea +### Domain name +GITEA_DOMAIN= +### Hostname +GITEA_HOST=gitea_app_1 diff --git a/nginx/sites-available/gitea.conf.template b/nginx/sites-available/gitea.conf.template new file mode 100644 index 0000000..477f4be --- /dev/null +++ b/nginx/sites-available/gitea.conf.template @@ -0,0 +1,23 @@ +server { + # SSL Key locations + ssl_certificate /etc/letsencrypt/live/${GITEA_DOMAIN}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/${GITEA_DOMAIN}/privkey.pem; + + listen ${HTTPS_PORT} ssl; + listen [::]:${HTTPS_PORT} ssl; + server_name ${GITEA_DOMAIN}; + + location / { + resolver 127.0.0.11; + proxy_pass http://#{GITEA_HOST}:3000/; + + # Static content caching + location ~* \.(?:jpg|jpeg|png|gif|ico|css|js|ttf)$ { + expires 1h; + add_header Cache-Control public; + + proxy_pass http://${GITEA_HOST}:3000; + } + } +} +