/
/
/
Ansible role that deployes services on my runner machine
1
2services:
3 forgejo:
4 container_name: forgejo
5 image: {{ container_images.forgejo }}
6 restart: unless-stopped
7
8 env_file:
9 - .env
10
11 volumes:
12 # Fast local storage for data
13 - {{ forgejo_config_dir }}/data:/data
14
15 # Bulk NFS storage for repositories
16 - {{ forgejo_data_dir }}:/repos
17
18 ports:
19 - "{{ forgejo_http_port }}:3000"
20 - "{{ forgejo_ssh_port }}:22"
21
22 networks:
23 - {{ runner_docker_network }}
24
25 healthcheck:
26 test: ["CMD", "wget", "-qO-", "http://localhost:3000/api/healthz"]
27 interval: 10s
28 timeout: 5s
29 retries: 12
30
31{% if forgejo_runner_enabled %}
32 forgejo-runner:
33 container_name: forgejo-runner
34 build:
35 context: .
36 dockerfile: Dockerfile
37 restart: unless-stopped
38 depends_on:
39 forgejo:
40 condition: service_healthy
41 environment:
42 - TZ=${TZ}
43 - FORGEJO_RUNNER_TOKEN=${FORGEJO_RUNNER_TOKEN}
44 - FORGEJO_EXTERNAL_URL=${FORGEJO_EXTERNAL_URL}
45 volumes:
46 - {{ forgejo_config_dir }}/forgejo-runner-data:/data
47 - /var/run/docker.sock:/var/run/docker.sock
48 command: ["/bin/bash","-lc",
49 "until wget -qO- ${FORGEJO_EXTERNAL_URL}/api/healthz >/dev/null 2>&1; do sleep 1; done; \
50 if [ ! -f /data/.runner ]; then \
51 forgejo-runner register --no-interactive \
52 --instance ${FORGEJO_EXTERNAL_URL} \
53 --name runner-host \
54 --token ${FORGEJO_RUNNER_TOKEN} \
55 --labels 'ubuntu-latest:host'; \
56 fi; \
57 exec forgejo-runner daemon --config /data/config.yaml"
58 ]
59
60{% endif %}
61{% if forgejo_ansible_runner_enabled | default(false) %}
62 forgejo-ansible-runner:
63 container_name: forgejo-ansible-runner
64 build:
65 context: .
66 dockerfile: Dockerfile.ansible
67 restart: unless-stopped
68 depends_on:
69 forgejo:
70 condition: service_healthy
71 environment:
72 - TZ=${TZ}
73 - FORGEJO_ANSIBLE_RUNNER_TOKEN=${FORGEJO_ANSIBLE_RUNNER_TOKEN}
74 - FORGEJO_EXTERNAL_URL=${FORGEJO_EXTERNAL_URL}
75 volumes:
76 - {{ forgejo_config_dir }}/forgejo-ansible-runner-data:/data
77 - /var/run/docker.sock:/var/run/docker.sock
78 command: ["/bin/bash","-lc",
79 "until wget -qO- ${FORGEJO_EXTERNAL_URL}/api/healthz >/dev/null 2>&1; do sleep 1; done; \
80 if [ ! -f /data/.runner ]; then \
81 forgejo-runner register --no-interactive \
82 --instance ${FORGEJO_EXTERNAL_URL} \
83 --name {{ forgejo_ansible_runner_name }} \
84 --token ${FORGEJO_ANSIBLE_RUNNER_TOKEN} \
85 --labels 'ansible:host'; \
86 fi; \
87 exec forgejo-runner daemon --config /data/config.yaml"
88 ]
89
90{% endif %}
91
92networks:
93 {{ runner_docker_network }}:
94 external: true
95