70 lines
3.3 KiB
Django/Jinja
70 lines
3.3 KiB
Django/Jinja
#jinja2: lstrip_blocks: "True"
|
|
[Unit]
|
|
Description=Forgejo Runner ({{ forgejo_runner_identifier }})
|
|
{% for service in forgejo_runner_systemd_required_services_list %}
|
|
Requires={{ service }}
|
|
After={{ service }}
|
|
{% endfor %}
|
|
DefaultDependencies=no
|
|
|
|
[Service]
|
|
Type=simple
|
|
Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
|
|
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill {{ forgejo_runner_identifier }} 2>/dev/null || true'
|
|
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ forgejo_runner_identifier }} 2>/dev/null || true'
|
|
|
|
ExecStartPre={{ devture_systemd_docker_base_host_command_sh }} -c '[ ! -f {{ forgejo_runner_config_path }}/.runner ] && \
|
|
{{ devture_systemd_docker_base_host_command_docker }} run \
|
|
--rm \
|
|
--user={{ forgejo_runner_uid }}:{{ forgejo_runner_gid }} \
|
|
--log-driver=none \
|
|
--cap-drop=ALL \
|
|
--network={{ forgejo_runner_container_network }} \
|
|
--mount type=bind,src={{ forgejo_runner_config_path }},dst=/data \
|
|
--tmpfs=/tmp:rw,noexec,nosuid,size=1024m \
|
|
{% for volume in forgejo_runner_container_additional_volumes %}
|
|
--mount type={{ volume.type | default('bind' if '/' in volume.src else 'volume') }},src={{ volume.src }},dst={{ volume.dst }}{{ (',' + volume.options) if volume.options | default('') else '' }} \
|
|
{% endfor %}
|
|
{% for arg in forgejo_runner_container_extra_arguments %}
|
|
{{ arg }} \
|
|
{% endfor %}
|
|
{{ forgejo_runner_container_image }} \
|
|
forgejo-runner register \
|
|
--no-interactive \
|
|
--name {{ forgejo_runner_runner_name }} \
|
|
--instance {{ forgejo_runner_instance_url }} \
|
|
--token {{ forgejo_runner_registration_token }} \
|
|
--config /data/config.yaml'
|
|
|
|
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
|
|
--rm \
|
|
--name={{ forgejo_runner_identifier }} \
|
|
--user={{ forgejo_runner_uid }}:{{ forgejo_runner_gid }} \
|
|
--log-driver=none \
|
|
--cap-drop=ALL \
|
|
--network={{ forgejo_runner_container_network }} \
|
|
--mount type=bind,src={{ forgejo_runner_config_path }},dst=/data \
|
|
--tmpfs=/tmp:rw,noexec,nosuid,size=1024m \
|
|
{% for volume in forgejo_runner_container_additional_volumes %}
|
|
--mount type={{ volume.type | default('bind' if '/' in volume.src else 'volume') }},src={{ volume.src }},dst={{ volume.dst }}{{ (',' + volume.options) if volume.options | default('') else '' }} \
|
|
{% endfor %}
|
|
{% for arg in forgejo_runner_container_extra_arguments %}
|
|
{{ arg }} \
|
|
{% endfor %}
|
|
{{ forgejo_runner_container_image }}
|
|
|
|
{% for network in forgejo_runner_container_additional_networks %}
|
|
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} {{ forgejo_runner_identifier }}
|
|
{% endfor %}
|
|
|
|
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach {{ forgejo_runner_identifier }}
|
|
|
|
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill {{ forgejo_runner_identifier }} 2>/dev/null || true'
|
|
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ forgejo_runner_identifier }} 2>/dev/null || true'
|
|
|
|
Restart=always
|
|
RestartSec=30
|
|
SyslogIdentifier={{ forgejo_runner_identifier }}
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|