From c9c58a6c43850d7d5eea17fac4fbb5a2a4acb086 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Mon, 19 Jun 2023 11:54:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20Gi?= =?UTF-8?q?tea=20=D0=B4=D0=BB=D1=8F=20=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ansible/configuration.yml | 20 ++++++++++++++++++++ ansible/templates/Caddyfile.j2 | 16 ++++++++++++++++ app/gitea/.env | 3 +++ app/gitea/.gitignore | 1 + app/gitea/docker-compose.yml | 16 ++++++++++++++++ app/gitea/tasks.py | 20 ++++++++++++++++++++ 6 files changed, 76 insertions(+) create mode 100644 app/gitea/.env create mode 100644 app/gitea/.gitignore create mode 100644 app/gitea/docker-compose.yml create mode 100644 app/gitea/tasks.py diff --git a/ansible/configuration.yml b/ansible/configuration.yml index e647f77..8931d20 100644 --- a/ansible/configuration.yml +++ b/ansible/configuration.yml @@ -9,6 +9,7 @@ wiki_port: "{{ base_port + 5 }}" nomie_port: "{{ base_port + 6 }}" nomie_db_port: "{{ base_port + 7 }}" + gitea_port: "{{ base_port + 8 }}" vars_files: - vars/vars.yml @@ -148,3 +149,22 @@ COUCH_DB_PASSWORD: '{{ nomie.couch_db_password }}' tags: - apps + + - import_role: + name: docker-app + vars: + username: gitea + extra_groups: + - docker + ssh_keys: + - '{{ lookup("file", "files/av_id_rsa.pub") }}' + env: + PROJECT_NAME: gitea + DOCKER_PREFIX: gitea + IMAGE_PREFIX: gitea + CONTAINER_PREFIX: gitea + WEB_SERVER_PORT: '127.0.0.1:{{ gitea_port }}' + USER_UID: '{{ uc_result.uid }}' + USER_GID: '{{ uc_result.group }}' + tags: + - apps diff --git a/ansible/templates/Caddyfile.j2 b/ansible/templates/Caddyfile.j2 index 40afb55..1eb5632 100644 --- a/ansible/templates/Caddyfile.j2 +++ b/ansible/templates/Caddyfile.j2 @@ -1,3 +1,11 @@ +# ------------------------------------------------------------------- +# Global options +# ------------------------------------------------------------------- + +{ + grace_period 15s +} + # ------------------------------------------------------------------- # Proxy services # ------------------------------------------------------------------- @@ -46,3 +54,11 @@ nomie-db.vakhrushev.me { to 127.0.0.1:{{ nomie_db_port }} } } + +git.vakhrushev.me { + tls anwinged@ya.ru + + reverse_proxy { + to 127.0.0.1:{{ gitea_port }} + } +} diff --git a/app/gitea/.env b/app/gitea/.env new file mode 100644 index 0000000..492cf5e --- /dev/null +++ b/app/gitea/.env @@ -0,0 +1,3 @@ +WEB_SERVER_PORT=9494 +USER_UID=1000 +USER_GID=1000 diff --git a/app/gitea/.gitignore b/app/gitea/.gitignore new file mode 100644 index 0000000..8fce603 --- /dev/null +++ b/app/gitea/.gitignore @@ -0,0 +1 @@ +data/ diff --git a/app/gitea/docker-compose.yml b/app/gitea/docker-compose.yml new file mode 100644 index 0000000..5bb4511 --- /dev/null +++ b/app/gitea/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3" + +services: + + server: + image: gitea/gitea:1.19.3 + environment: + - "USER_UID=${USER_UID}" + - "USER_GID=${USER_GID}" + restart: unless-stopped + volumes: + - ./data:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "${WEB_SERVER_PORT}:3000" diff --git a/app/gitea/tasks.py b/app/gitea/tasks.py new file mode 100644 index 0000000..b290c1f --- /dev/null +++ b/app/gitea/tasks.py @@ -0,0 +1,20 @@ +from fabric import Connection +from invoke import task +import shlex + +APP_NAME = "gitea" +SSH_HOST = f"{APP_NAME}@51.250.85.23" +DOCKER_REGISTRY = "cr.yandex/crplfk0168i4o8kd7ade" + + +@task +def deploy(c): + print("Ready to setup remote host") + with Connection(SSH_HOST) as c: + c.put( + local="docker-compose.yml", + remote=f"/home/{APP_NAME}/docker-compose.yml", + ) + c.run("cp .env .env.prod") + c.run("mkdir -p data") + c.run(f"docker-compose --project-name {shlex.quote(APP_NAME)} --env-file=.env.prod up --detach --remove-orphans")