Skip to content

Gitea Stack

Auto Documentation

Documentation Generated with Python on 2021-04-03

Default Variables

Tasks

main.yml

- include: postgres.yml
- include: gitea.yml

postgres.yml

- name: Ensure Postgres Data Directory Exist
  file:
    path: "{{ docker_dir }}/postgres"
    state: directory

- name: Create Postgres Docker Container
  docker_container:
    name: gitea-postgres
    image: "postgres:9.6"
    hostname: postgres
    restart_policy: unless-stopped
    published_ports:
      - 5432:5432
    networks:
      - name: web
    env:
      POSTGRES_USER: "{{ gitea_pg_un }}"
      POSTGRES_PASSWORD: "{{ gitea_pg_pw }}"
      POSTGRES_DB: "gitea"
    volumes:
      - "{{ docker_dir }}/postgres:/var/lib/postgresql/data"

- name: Wait for Postgres to accept connections
  wait_for:
    host: "localhost"
    port: "5432"
    state: drained
    connect_timeout: 1
    timeout: 30
  register: postgres_running
  until: postgres_running is success
  retries: 10
  tags: postgres

gitea.yml

- name: Ensure Gitea Directory Exist
  file:
    path: "{{ docker_dir }}/gitea"
    state: directory

- name: Create Gitea Docker Container
  docker_container:
    name: gitea
    image: "gitea/gitea:1"
    hostname: gitea
    restart_policy: unless-stopped
    published_ports:
      - "2223:22"
    #   - "{{ proxy.gitea.port }}:3000"
    networks:
      - name: web
    state: started
    env:
      USER_UID: "1000"
      USER_GID: "1000"
      DB_TYPE: postgres
      DB_HOST: gitea-postgres:5432
      DB_NAME: "gitea"
      DB_USER: "{{ gitea_pg_un }}"
      DB_PASSWD: "{{ gitea_pg_pw }}"
      # DOMAIN: "{{proxy.gitea.subdomain}}.{{primary_domain}}"
      ROOT_URL: "https://{{proxy.gitea.subdomain}}.{{primary_domain}}"
      DISABLE_REGISTRATION: "true"
      REQUIRE_SIGNIN_VIEW: "true"
    volumes:
      - "{{ docker_dir }}/gitea:/data"
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro

Handlers

main.yml

- name: Restart Postgres
  docker_container:
    name: database
    restart: yes
  listen: restart postgres