Use sysusers and tmpfiles in plain dockerd setup

This commit is contained in:
2025-01-26 16:08:25 +01:00
parent d8a6a940dd
commit b297f76612
4 changed files with 28 additions and 10 deletions
+3
View File
@@ -0,0 +1,3 @@
#Type Name ID GECOS Home directory Shell
u act-runner - "act_runner user" /var/lib/act-runner -
m act-runner docker
+2
View File
@@ -0,0 +1,2 @@
d /var/lib/act-runner 0700 act-runner act-runner -
d /var/lib/act-runner/act_runner 0700 act-runner act-runner -
+3 -2
View File
@@ -4,8 +4,9 @@ Documentation=https://gitea.com/gitea/act_runner
After=docker.service
[Service]
Environment=XDG_RUNTIME_DIR=/run/user/%U
Environment=DOCKER_HOST=unix:///run/docker.sock
# Environment=XDG_RUNTIME_DIR=/run/user/%U
# Environment=DOCKER_HOST=unix:///run/docker.sock
User=act-runner
ExecStart=/usr/bin/act_runner daemon -c /etc/gitea-act-runner/config.yaml
ExecReload=/bin/kill -s HUP $MAINPID
WorkingDirectory=%h/act_runner
+20 -8
View File
@@ -31,7 +31,8 @@ Source3: %{dockerd_rootless_service}
Source4: README-%{dockerd}.md
Source5: README-%{rootless}-%{dockerd}.md
Source6: rootless-act_runner-register.sh
Source7: %{name}-sysusers.conf
Source8: %{name}-tmpfiles.conf
BuildRequires: go >= 1.23
BuildRequires: go-rpm-macros
BuildRequires: git-core
@@ -40,25 +41,22 @@ BuildRequires: git-core
%description %{common_description}
# #############################################################
# act_runner with dockerd package
%package %{dockerd}
Summary: Enable running gitea actions in docker containers
Requires: %{name} docker-ce
Conflicts: %{name}-%{dockerd_rootless}
BuildRequires: systemd-rpm-macros
%{?sysusers_requires_compat}
%{?%systemd_requires}
%description %{dockerd}
%{common_description}
Run gitea actions in docker containers
%pre %{dockerd}
if [ $1 -eq 1 ]; then
getent group '%{runner_user}' >/dev/null || groupadd -r '%{runner_user}' || :
getent passwd '%{runner_user}' >/dev/null || \
useradd -r -m -F -g '%{runner_user}' -d '/home/%{runner_user}' -s '/sbin/nologin' -c 'act_runner user' '%{runner_user}' || :
fi
%sysusers_create_package %{name} %{SOURCE7}
%tmpfiles_create_package %{name} %{SOURCE8}
%post %{dockerd}
%systemd_post %{act_runner_service}
@@ -67,11 +65,14 @@ fi
%systemd_preun %{act_runner_service}
%postun %{dockerd}
%systemd_postun %{act_runner_service}
if [ $1 -eq 0 ]; then
userdel -rf %{runner_user}
fi
# #############################################################
# #############################################################
# act_runner with rootless dockerd package
%package %{dockerd_rootless}
Summary: Enable running gitea actions in non-root docker containers
@@ -79,6 +80,7 @@ Summary: Enable running gitea actions in non-root docker containers
Requires: %{name} docker-ce slirp4netns fuse-overlayfs iptables docker-ce-rootless-extras shadow-utils
Conflicts: %{name}-%{dockerd}
BuildRequires: systemd-rpm-macros
%{?%systemd_requires}
%description %{dockerd_rootless}
%{common_description}
@@ -105,10 +107,14 @@ if [ $1 -eq 0 ]; then
fi
%postun %{dockerd_rootless}
%systemd_user_postun %{dockerd_rootless_service} %{act_runner_rootless_service}
if [ $1 -eq 0 ]; then
CREATE_MAIL_SPOOL=false userdel -rf %{runner_user_rootless}
fi
# #############################################################
%prep
%autosetup -p1 -C
%{__cp} %{SOURCE4} %{SOURCE5} .
@@ -125,6 +131,9 @@ install -m 0755 -vp bin/* %{buildroot}%{_bindir}
install -m 0755 -vd %{buildroot}%{_unitdir}
install -m 0755 -vd %{buildroot}%{_sysconfdir}/%{name}
install -D -m 0644 -vp %{SOURCE1} %{buildroot}%{_unitdir}/%{act_runner_service}
install -D %{SOURCE7} %{buildroot}%{_sysusersdir}/%{name}.conf
install -D %{SOURCE8} %{buildroot}%{_tmpfilesdir}/%{name}.conf
bin/act_runner generate-config > %{buildroot}%{_sysconfdir}/%{name}/config.yaml
# dockerd-rootless
install -m 0755 -vd %{buildroot}%{_userunitdir}
@@ -142,7 +151,10 @@ install -D -m 0755 -vp %{SOURCE6} %{buildroot}%{_datadir}/%{name}/rootless-act_r
%license LICENSE
%doc README-%{dockerd}.md
%dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/%{name}/config.yaml
%{_unitdir}/*
%{_sysusersdir}/%{name}.conf
%{_tmpfilesdir}/%{name}.conf
%files %{dockerd_rootless}
%license LICENSE