I am trying to run a gitea server with https using certbot.
For this purpose I am using docker compose:
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.20
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- FORGEJO__database__DB_TYPE=postgres
- FORGEJO__database__HOST=db:5432
- FORGEJO__database__NAME= gitea
- FORGEJO__database__USER= gitea
- FORGEJO__database__PASSWD= gitea
restart: unless-stopped
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ./etc/letsencrypt:/etc/letsencrypt
ports:
- "443:443"
- "222:22"
depends_on:
- db
- certbot
db:
image: postgres:14
restart: unless-stopped
environment:
- POSTGRES_USER= gitea
- POSTGRES_PASSWORD= gitea
- POSTGRES_DB= gitea
networks:
- gitea
volumes:
- ./postgres:/var/lib/postgresql/data
certbot:
container_name: certbot
build: .
command: >
certonly
...
volumes:
- ./etc/letsencrypt:/etc/letsencrypt
- ./certbot/data:/var/www/certbot
- ./certbot/logs:/var/log/letsencrypt
I know that the certificates are there, but there is a problem with the permissions.
The certificates have one 700 accessibility by root.
Now if I run the container of gitea I get the following error:
cmd/web_https.go:170:runHTTPS() [E] Failed to load https cert file /etc/letsencrypt/live/mydomain.com/cert.pem for tcp:0.0.0.0:443: open /etc/letsencrypt/live/mydomain.com/cert.pem: permission denied
which makes kind of sense. I do not want to reduce the security level of the certificates of course, so I tried running gitea with root by changing the user in the docker-compose.yml
file
- USER_UID=0
- USER_GID=0
which only yielded the following error message:
[F] Gitea is not supposed to be run as root. Sorry. If you need to use privileged TCP ports please instead use setcap and the `cap_net_bind_service` permission
which I do not understand. I do not think I am looking for a privileged TCP port, but I just want gitea to be able to access the certificates without having to expose them publicly.
I am not sure what to do? Is this something that is supported?