From 1beb83af5a83d41e889422c81453fbcb82516b31 Mon Sep 17 00:00:00 2001 From: Opnxng Date: Thu, 9 Nov 2023 18:25:07 +0800 Subject: [PATCH] Gitea: switched to rootless image --- .../{conf => data/config}/example.app.ini | 0 .../custom/public}/css/theme-github.css | 0 .../custom}/templates/custom/extra_links.tmpl | 0 setups/setup-gitea.yml | 14 ++++-- templates/compose/gitea.yaml.j2 | 45 +++++++++++++------ templates/compose/runner.yaml.j2 | 2 +- vars/services.yml | 10 +---- 7 files changed, 46 insertions(+), 25 deletions(-) rename files/gitea/{conf => data/config}/example.app.ini (100%) rename files/gitea/{public/assets => data/custom/public}/css/theme-github.css (100%) mode change 100644 => 100755 rename files/gitea/{ => data/custom}/templates/custom/extra_links.tmpl (100%) mode change 100644 => 100755 diff --git a/files/gitea/conf/example.app.ini b/files/gitea/data/config/example.app.ini similarity index 100% rename from files/gitea/conf/example.app.ini rename to files/gitea/data/config/example.app.ini diff --git a/files/gitea/public/assets/css/theme-github.css b/files/gitea/data/custom/public/css/theme-github.css old mode 100644 new mode 100755 similarity index 100% rename from files/gitea/public/assets/css/theme-github.css rename to files/gitea/data/custom/public/css/theme-github.css diff --git a/files/gitea/templates/custom/extra_links.tmpl b/files/gitea/data/custom/templates/custom/extra_links.tmpl old mode 100644 new mode 100755 similarity index 100% rename from files/gitea/templates/custom/extra_links.tmpl rename to files/gitea/data/custom/templates/custom/extra_links.tmpl diff --git a/setups/setup-gitea.yml b/setups/setup-gitea.yml index a2ff3b5..4939a84 100644 --- a/setups/setup-gitea.yml +++ b/setups/setup-gitea.yml @@ -1,11 +1,19 @@ - name: Copy gitea directory copy: src: "gitea/" - dest: "{{ docker_dir }}/gitea/data/gitea" + dest: "{{ docker_dir }}/gitea" owner: 1000 group: 1000 mode: 0755 + - name: Set proper chown + command: chown -R 1000:1000 '{{ docker_dir }}/gitea' + become: true + + - name: Set proper permissions + command: chmod 755 '{{ docker_dir }}/gitea' + become: true + - name: Curl Github theme - shell: curl -s 'https://raw.githubusercontent.com/Rainnny7/gitea-github-theme/master/theme-github.css' > {{ docker_dir }}/gitea/data/gitea/public/assets/css/theme-github.css - ignore_errors: true + shell: curl -s 'https://raw.githubusercontent.com/Rainnny7/gitea-github-theme/master/theme-github.css' > {{ docker_dir }}/gitea/data/public/assets/css/theme-github.css + ignore_errors: true \ No newline at end of file diff --git a/templates/compose/gitea.yaml.j2 b/templates/compose/gitea.yaml.j2 index 2d79705..4d02d72 100644 --- a/templates/compose/gitea.yaml.j2 +++ b/templates/compose/gitea.yaml.j2 @@ -2,37 +2,56 @@ version: "3" services: gitea: - image: gitea/gitea:nightly + image: gitea/gitea:latest-rootless container_name: gitea security_opt: - no-new-privileges environment: - PUID=1000 - PGID=1000 -# - TZ=Asia/Singapore - USER_UID=1000 - USER_GID=1000 + - TZ=Asia/Singapore - ROOT_URL=https://git.opnxng.com + - GITEA_DATABASE_DB_TYPE=postgres + - GITEA_DATABASE_HOST=gitea-db:5432 + - GITEA_DATABASE_NAME={{ gitea_database_name }} + - GITEA_DATABASE_USER={{ gitea_database_user }} + - GITEA_DATABASE_PASSWD={{ gitea_database_passwd }} volumes: - - {{ docker_dir }}/gitea/data:/data + - {{ docker_dir }}/gitea/data:/var/lib/gitea + - {{ docker_dir }}/gitea/data/config:/etc/gitea - {{ docker_dir }}/gitea/packages:/packages - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro restart: always + depends_on: + - gitea-db ports: - "3000:3000" - labels: - - "com.centurylinklabs.watchtower.enable=false" networks: - IPv4 + + + gitea-db: + image: postgres:14 + container_name: gitea-db + security_opt: + - no-new-privileges + environment: + - PUID=1000 + - PGID=1000 + - TZ=Asia/Singapore + - POSTGRES_USER={{ gitea_database_user }} + - POSTGRES_PASSWORD={{ gitea_database_passwd }} + - POSTGRES_DB={{ gitea_database_name }} + volumes: + - {{ docker_dir }}/gitea/data/postgres:/var/lib/postgresql/data + restart: always + networks: + - IPv4 + networks: IPv4: external: - name: IPv4 - -# Don't auto-update for now. Switch to stable rootless later -# image: gitea/gitea:latest-rootless -# - GITEA_APP_INI=/data/gitea/conf/app.ini -# - GITEA_TEMP=/data/gitea/tmp -# - GITEA_CUSTOM=/data/gitea -# - GITEA_WORK_DIR=/app/gitea/gitea \ No newline at end of file + name: IPv4 \ No newline at end of file diff --git a/templates/compose/runner.yaml.j2 b/templates/compose/runner.yaml.j2 index 1a7fe93..4e1fd91 100755 --- a/templates/compose/runner.yaml.j2 +++ b/templates/compose/runner.yaml.j2 @@ -19,7 +19,7 @@ services: - DOCKER_HOST={{ docker_host }} - GITEA_INSTANCE_URL=https://git.opnxng.com - GITEA_RUNNER_NAME=runner - - GITEA_RUNNER_REGISTRATION_TOKEN="{{ gitea_runner_registration_token }}" + - GITEA_RUNNER_REGISTRATION_TOKEN={{ gitea_runner_registration_token }} - GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster,runner:host networks: - IPv4 diff --git a/vars/services.yml b/vars/services.yml index 481dea2..12b1923 100644 --- a/vars/services.yml +++ b/vars/services.yml @@ -1,12 +1,6 @@ -setup: - oracle4: - - paulgo - - nitter - compose: - oracle4: - - paulgo - - nitter + oracle3: + - gitea # ----------------------------------------------------------------------------------------------------