From d290f2f68f73809c9d29ecda758141aaab081eea Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 17 Feb 2020 21:46:50 +0000 Subject: [PATCH] Use cgit as a simple frontend to gitea --- ansible/roles/docker/files/gitea/app.ini | 2 +- ansible/roles/docker/files/gitea/cgitrc | 11 +++++++ .../docker/files/gitea/docker-compose.yml | 31 ++++++++++++++++++- ansible/roles/docker/tasks/gitea.yml | 29 +++++++++++++++-- 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/docker/files/gitea/cgitrc diff --git a/ansible/roles/docker/files/gitea/app.ini b/ansible/roles/docker/files/gitea/app.ini index e6c76fe..d8f9cad 100644 --- a/ansible/roles/docker/files/gitea/app.ini +++ b/ansible/roles/docker/files/gitea/app.ini @@ -15,7 +15,7 @@ TEMP_PATH = /data/gitea/uploads APP_DATA_PATH = /data/gitea SSH_DOMAIN = git.theorangeone.net HTTP_PORT = 3000 -ROOT_URL = https://git.theorangeone.net/ +ROOT_URL = https://git.theorangeone.net/gitea/ DISABLE_SSH = false SSH_PORT = 22 SSH_LISTEN_PORT = 3022 diff --git a/ansible/roles/docker/files/gitea/cgitrc b/ansible/roles/docker/files/gitea/cgitrc new file mode 100644 index 0000000..43278c2 --- /dev/null +++ b/ansible/roles/docker/files/gitea/cgitrc @@ -0,0 +1,11 @@ +# +# cgit config +# + +css=/cgit.css +logo=/cgit.png +source-filter=/bin/syntax-highlighting.sh +virtual-root=/ +mimetype-file=/etc/mime.types +robots=noindex, nofollow +include=/config/repos.txt diff --git a/ansible/roles/docker/files/gitea/docker-compose.yml b/ansible/roles/docker/files/gitea/docker-compose.yml index 3af74f4..76d6485 100644 --- a/ansible/roles/docker/files/gitea/docker-compose.yml +++ b/ansible/roles/docker/files/gitea/docker-compose.yml @@ -10,10 +10,12 @@ services: - USER_GID={{ docker_user.id }} labels: - "traefik.enable=true" - - "traefik.http.routers.gitea.rule=Host(`git.theorangeone.net`)" + - "traefik.http.routers.gitea.rule=Host(`git.theorangeone.net`) && PathPrefix(`/gitea`)" - "traefik.http.routers.gitea.tls=true" - "traefik.http.routers.gitea.tls.certresolver=le" - "traefik.http.services.gitea-gitea.loadbalancer.server.port=3000" + - "traefik.http.middlewares.gitea-strip.stripprefix.prefixes=/gitea" + - "traefik.http.routers.gitea.middlewares=gitea-strip" ports: - "{{ wireguard.clients.intersect.ip }}:3022:3022" volumes: @@ -30,3 +32,30 @@ services: environment: - POSTGRES_PASSWORD=gitea - POSTGRES_USER=gitea + + cgit: + image: theorangeone/docker-cgit:latest + container_name: cgit + restart: unless-stopped + environment: + - USER_UID={{ docker_user.id }} + - USER_GID={{ docker_user.id }} + volumes: + - ./repos:/data/git:ro + - ./cgit/cgitrc:/config/cgitrc:ro + - ./cgit/repos.txt:/config/repos.txt:ro + labels: + - "traefik.enable=true" + - "traefik.http.routers.cgit.rule=Host(`git.theorangeone.net`)" + - "traefik.http.routers.cgit.tls=true" + - "traefik.http.routers.cgit.tls.certresolver=le" + + gitea-cgit-adapter: + image: theorangeone/gitea-cgit-adapter:latest + restart: unless-stopped + command: "/app/gitea-cgit-adapter /etc/gitea.ini /etc/cgit-repos.txt --interval 600" + depends_on: + - gitea + volumes: + - ./gitea/gitea/conf/app.ini:/etc/gitea.ini:ro + - ./cgit/repos.txt:/etc/cgit-repos.txt diff --git a/ansible/roles/docker/tasks/gitea.yml b/ansible/roles/docker/tasks/gitea.yml index 276f8cc..a7a84e2 100644 --- a/ansible/roles/docker/tasks/gitea.yml +++ b/ansible/roles/docker/tasks/gitea.yml @@ -18,6 +18,14 @@ become: true become_user: root +- name: Create cgit config directory + file: + path: '/opt/gitea/cgit' + state: directory + mode: "{{ docker_compose_directory_mask }}" + become: true + become_user: root + - name: Install gitea compose file template: src: files/gitea/docker-compose.yml @@ -35,7 +43,24 @@ dest: "/opt/gitea/gitea/gitea/conf/app.ini" mode: "{{ docker_compose_file_mask }}" owner: "{{ docker_user.name }}" - register: config_file + register: gitea_config_file + become: true + become_user: root + +- name: Install cgit config file + template: + src: files/gitea/cgitrc + dest: "/opt/gitea/cgit/cgitrc" + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + register: cgit_config_file + become: true + become_user: root + +- name: Touch public repos file + file: + path: /opt/gitea/cgit/repos.txt + state: file become: true become_user: root @@ -46,7 +71,7 @@ remove_orphans: true remove_volumes: true state: "{{ item }}" - when: compose_file.changed or config_file.changed + when: compose_file.changed or gitea_config_file.changed or cgit_config_file.changed loop: - absent - present