From 504e2e4b4c5b45516e496769ab44cb4285b446bf Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sun, 15 Oct 2023 21:06:26 +0200 Subject: [PATCH] Replace gitlab by gitea (Reduce RAM and CPU Usage) --- playbook.yml | 3 +- roles/gitea/tasks/base.yml | 22 ++++++++++++ roles/gitea/tasks/main.yml | 4 +++ roles/gitea/templates/docker-compose.yml | 44 ++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 roles/gitea/tasks/base.yml create mode 100644 roles/gitea/tasks/main.yml create mode 100644 roles/gitea/templates/docker-compose.yml diff --git a/playbook.yml b/playbook.yml index 07ad71a..bca602f 100644 --- a/playbook.yml +++ b/playbook.yml @@ -16,7 +16,8 @@ - { role: home_assistant, tags: ["home_assistant"] } - { role: n8n, tags: ["n8n"] } - { role: matrix, tags: ["matrix"] } - - { role: gitlab, tags: ["gitlab"] } +# - { role: gitlab, tags: ["gitlab"] } + - { role: gitea, tags: ["gitea"] } - { role: iptables, tags: ["iptables"] } - { role: borg, tags: ["borg"] } - { role: watchtower, tags: ["watchtower"] } diff --git a/roles/gitea/tasks/base.yml b/roles/gitea/tasks/base.yml new file mode 100644 index 0000000..81c692d --- /dev/null +++ b/roles/gitea/tasks/base.yml @@ -0,0 +1,22 @@ +--- + +- name: Check gitea directory exist + ansible.builtin.file: + path: gitea + state: directory + +- name: Copy template conf + ansible.builtin.template: + src: "{{ item.src }}" + dest: "gitea/{{ item.dest }}" + loop: + - { src: 'docker-compose.yml', dest: 'docker-compose.yml' } + register: gitea_copy_templates_results + +- name: Update and restart container + community.docker.docker_compose: + project_src: gitea + state: present + pull: true + restarted: "{{ gitea_copy_templates_results.changed }}" + become: true \ No newline at end of file diff --git a/roles/gitea/tasks/main.yml b/roles/gitea/tasks/main.yml new file mode 100644 index 0000000..c4e7ea2 --- /dev/null +++ b/roles/gitea/tasks/main.yml @@ -0,0 +1,4 @@ +--- + +- ansible.builtin.import_tasks: base.yml + name: base diff --git a/roles/gitea/templates/docker-compose.yml b/roles/gitea/templates/docker-compose.yml new file mode 100644 index 0000000..bf64991 --- /dev/null +++ b/roles/gitea/templates/docker-compose.yml @@ -0,0 +1,44 @@ +version: "3" + +services: + gitea: + image: gitea/gitea:latest + environment: + - USER_UID=1000 + - USER_GID=1000 + container_name: gitea + restart: unless-stopped + volumes: + - {{ server.work_dir }}/gitea/data/:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + networks: + - proxy + - interne + labels: + - traefik.enable=true + - traefik.docker.network=proxy + # HTTP Reverse proxy Gitea + - traefik.http.routers.gitea-secure.entrypoints=https + - traefik.http.routers.gitea-secure.rule=Host(`gitea.{{ server.domain }}`) + - traefik.http.routers.gitea-secure.tls=true + - traefik.http.routers.gitea-secure.tls.certresolver=sslResolver + - traefik.http.routers.gitea-secure.service=gitea + - traefik.http.services.gitea.loadbalancer.server.port=3000 + # TCP SSH Reverse proxy Gitlab + - traefik.tcp.routers.gitea-ssh.rule=HostSNI(`*`) + - traefik.tcp.routers.gitea-ssh.entrypoints=ssh + - traefik.tcp.routers.gitea-ssh.service=gitea-ssh + - traefik.tcp.services.gitea-ssh.loadbalancer.server.port=22 + logging: + driver: loki + options: + loki-url: "https://lokidoki:vEGH5Z5siWgcDkNknvCVzPCyqhHSBJCBjeBRZJvxUP8SdgfxJ6AqCGutCWugGsx5@loki.mrdev023.fr/loki/api/v1/push" + mode: non-blocking + +networks: + interne: + metrics: + external: true + proxy: + external: true \ No newline at end of file