Add dockerd subpackage
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
# Gitea act runner
|
||||
|
||||
Act runner is a runner for Gitea based on Gitea fork of act.
|
||||
|
||||
## Quickstart
|
||||
|
||||
Actions are disabled by default, so you need to add the following to the configuration file of your Gitea instance to enable it:
|
||||
|
||||
```ini
|
||||
[actions]
|
||||
ENABLED=true
|
||||
```
|
||||
|
||||
### Register
|
||||
|
||||
```bash
|
||||
./act_runner register
|
||||
```
|
||||
|
||||
And you will be asked to input:
|
||||
|
||||
1. Gitea instance URL, like `http://192.168.8.8:3000/`. You should use your gitea instance ROOT_URL as the instance argument
|
||||
and you should not use `localhost` or `127.0.0.1` as instance IP;
|
||||
2. Runner token, you can get it from `http://192.168.8.8:3000/admin/actions/runners`;
|
||||
3. Runner name, you can just leave it blank;
|
||||
4. Runner labels, you can just leave it blank.
|
||||
|
||||
The process looks like:
|
||||
|
||||
```text
|
||||
INFO Registering runner, arch=amd64, os=darwin, version=0.1.5.
|
||||
WARN Runner in user-mode.
|
||||
INFO Enter the Gitea instance URL (for example, https://gitea.com/):
|
||||
http://192.168.8.8:3000/
|
||||
INFO Enter the runner token:
|
||||
fe884e8027dc292970d4e0303fe82b14xxxxxxxx
|
||||
INFO Enter the runner name (if set empty, use hostname: Test.local):
|
||||
|
||||
INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, ubuntu-latest:docker://gitea/runner-images:ubuntu-latest):
|
||||
|
||||
INFO Registering runner, name=Test.local, instance=http://192.168.8.8:3000/, labels=[ubuntu-latest:docker://gitea/runner-images:ubuntu-latest ubuntu-22.04:docker://gitea/runner-images:ubuntu-22.04 ubuntu-20.04:docker://gitea/runner-images:ubuntu-20.04].
|
||||
DEBU Successfully pinged the Gitea instance server
|
||||
INFO Runner registered successfully.
|
||||
```
|
||||
|
||||
You can also register with command line arguments.
|
||||
|
||||
```bash
|
||||
./act_runner register --instance http://192.168.8.8:3000 --token <my_runner_token> --no-interactive
|
||||
```
|
||||
|
||||
If the registry succeed, it will run immediately. Next time, you could run the runner directly.
|
||||
|
||||
### Run
|
||||
|
||||
```bash
|
||||
./act_runner daemon
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
You can also configure the runner with a configuration file.
|
||||
The configuration file is a YAML file, you can generate a sample configuration file with `./act_runner generate-config`.
|
||||
|
||||
```bash
|
||||
./act_runner generate-config > config.yaml
|
||||
```
|
||||
|
||||
You can specify the configuration file path with `-c`/`--config` argument.
|
||||
|
||||
```bash
|
||||
./act_runner -c config.yaml register # register with config file
|
||||
./act_runner -c config.yaml daemon # run with config file
|
||||
```
|
||||
|
||||
You can read the latest version of the configuration file online at [config.example.yaml](internal/pkg/config/config.example.yaml).
|
||||
|
||||
https://gitea.com/gitea/act_runner
|
||||
@@ -0,0 +1,22 @@
|
||||
# Gitea actions in rootless docker containers
|
||||
|
||||
This package configures a rootless docker instance owned by the docker-rootless user
|
||||
to enable gitea actions in a non-root docker environment.
|
||||
|
||||
## Post-installation steps
|
||||
|
||||
You have to start and register the docker instance with Gitea:
|
||||
|
||||
`sudo -u act-runner-rootless rootless-act_runner-register.sh`
|
||||
|
||||
You will be asked to input:
|
||||
|
||||
1. Gitea instance URL, like `http://192.168.8.8:3000/`. You should use your gitea instance ROOT_URL as the instance argument
|
||||
and you should not use `localhost` or `127.0.0.1` as instance IP;
|
||||
2. Runner token, you can get it from `http://192.168.8.8:3000/admin/actions/runners`;
|
||||
3. Runner name, you can just leave it blank;
|
||||
4. Runner labels, you can just leave it blank.
|
||||
|
||||
Apart from registering the docker instance, the script also produces a default config file in the `/home/act_runner` directory.
|
||||
|
||||
If you uninstall the package, you need to manually remove the registration in the Gitea UI.
|
||||
@@ -1,2 +0,0 @@
|
||||
#Type Name ID GECOS Home directory Shell
|
||||
u docker-rootless - "Rootless docker user" /home/docker-rootless /sbin/nologin
|
||||
@@ -0,0 +1,24 @@
|
||||
[Unit]
|
||||
Description=Docker Application Container Engine (Rootless)
|
||||
Documentation=https://docs.docker.com/go/rootless/
|
||||
Requires=dbus.socket
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/dockerd-rootless.sh
|
||||
ExecReload=/bin/kill -s HUP \$MAINPID
|
||||
TimeoutSec=0
|
||||
RestartSec=2
|
||||
Restart=always
|
||||
StartLimitBurst=3
|
||||
StartLimitInterval=60s
|
||||
LimitNOFILE=infinity
|
||||
LimitNPROC=infinity
|
||||
LimitCORE=infinity
|
||||
TasksMax=infinity
|
||||
Delegate=yes
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
KillMode=mixed
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -0,0 +1,2 @@
|
||||
#Type Name ID GECOS Home directory Shell
|
||||
u act-runner-rootless - "Rootless act_runner docker user" /home/act-runner-rootless /sbin/nologin
|
||||
@@ -0,0 +1,2 @@
|
||||
d /home/act-runner-rootless 0700 act-runner-rootless act-runner-rootless -
|
||||
d /home/act-runner-rootless/act_runner 0700 act-runner-rootless act-runner-rootless -
|
||||
@@ -0,0 +1,27 @@
|
||||
[Unit]
|
||||
Description=Gitea Actions runner using docker
|
||||
Documentation=https://gitea.com/gitea/act_runner
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Environment=XDG_RUNTIME_DIR=%h/.docker/run
|
||||
Environment=DOCKER_HOST=unix:///var/run/docker.sock
|
||||
ExecStart=/usr/bin/act_runner daemon -c %h/act_runner/config.yaml
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
WorkingDirectory=%h/act_runner
|
||||
TimeoutSec=0
|
||||
RestartSec=2
|
||||
Restart=always
|
||||
StartLimitBurst=3
|
||||
StartLimitInterval=60s
|
||||
LimitNOFILE=infinity
|
||||
LimitNPROC=infinity
|
||||
LimitCORE=infinity
|
||||
TasksMax=infinity
|
||||
Delegate=yes
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
KillMode=mixed
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -0,0 +1,2 @@
|
||||
#Type Name ID GECOS Home directory Shell
|
||||
u act-runner - "act_runner user" /home/act-runner /sbin/nologin
|
||||
@@ -0,0 +1,2 @@
|
||||
d /home/act-runner 0700 act-runner act-runner -
|
||||
d /home/act-runner/act_runner 0700 act-runner act-runner -
|
||||
@@ -1,12 +1,12 @@
|
||||
[Unit]
|
||||
Description=Gitea Actions runner using rootless docker
|
||||
Description=Gitea Actions runner using docker
|
||||
Documentation=https://gitea.com/gitea/act_runner
|
||||
After=docker-rootless.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Environment=XDG_RUNTIME_DIR=%h/.docker/run
|
||||
Environment=DOCKER_HOST=unix:///run/user/%U/docker.sock
|
||||
ExecStart=/usr/bin/act_runner daemon -c %h/act_runner/config
|
||||
Environment=DOCKER_HOST=unix:///var/run/docker.sock
|
||||
ExecStart=/usr/bin/act_runner daemon -c /etc/gitea-act-runner/config.yaml
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
WorkingDirectory=%h/act_runner
|
||||
TimeoutSec=0
|
||||
|
||||
+92
-33
@@ -1,7 +1,9 @@
|
||||
%global common_description %{expand:
|
||||
A runner for Gitea based on act.}
|
||||
|
||||
%global rootless_docker_user docker-rootless
|
||||
%global dockerd_package dockerd
|
||||
%global rootless rootless
|
||||
%global dockerd_package_rootless dockerd-%{rootless}
|
||||
%global act_runner_bin act_runner
|
||||
%global debug_package %{nil}
|
||||
|
||||
@@ -18,67 +20,124 @@ License: MIT
|
||||
URL: https://gitea.com/gitea/act_runner
|
||||
Source0: https://gitea.com/gitea/act_runner/archive/v%{version}.tar.gz
|
||||
Source1: %{name}.service
|
||||
Source2: %{rootless_docker_user}.service
|
||||
Source3: %{rootless_docker_user}-sysusers.conf
|
||||
Source4: %{rootless_docker_user}-tmpfiles.conf
|
||||
Source2: %{name}-sysusers.conf
|
||||
Source3: %{name}-tmpfiles.conf
|
||||
Source4: %{name}-%{rootless}.service
|
||||
Source5: %{name}-%{dockerd_package_rootless}.service
|
||||
Source6: %{name}-%{rootless}-sysusers.conf
|
||||
Source7: %{name}-%{rootless}-tmpfiles.conf
|
||||
Source8: README-%{dockerd_package}.md
|
||||
Source9: README-%{rootless}-%{dockerd_package}.md
|
||||
|
||||
BuildRequires: go >= 1.22
|
||||
BuildRequires: go-rpm-macros
|
||||
BuildRequires: git-core
|
||||
BuildRequires: systemd-rpm-macros
|
||||
BuildRequires: go >= 1.22
|
||||
BuildRequires: go-rpm-macros
|
||||
BuildRequires: git-core
|
||||
|
||||
%gometa -L -f
|
||||
|
||||
%description %{common_description}
|
||||
|
||||
%package %{rootless_docker_user}
|
||||
Summary: Run gitea actions in non-root docker containers
|
||||
|
||||
Requires: gitea-act-runner docker-ce slirp4netns fuse-overlayfs iptables docker-ce-rootless-extras
|
||||
Requires(post): shadow-utils shadow-utils-subid systemd-tmpfiles systemd-sysusers
|
||||
Requires(preun): shadow-utils shadow-utils-subid systemd-tmpfiles systemd-sysusers
|
||||
# act_runner with dockerd package
|
||||
%package %{dockerd_package}
|
||||
Summary: Enable running gitea actions in docker containers
|
||||
Requires: %{name} docker-ce
|
||||
Conflicts: %{name}-%{dockerd_package_rootless}
|
||||
BuildRequires: systemd-rpm-macros
|
||||
%{?sysusers_requires_compat}
|
||||
|
||||
%description %{rootless_docker_user}
|
||||
%description %{dockerd_package}
|
||||
%{common_description}
|
||||
Run gitea actions in docker containers
|
||||
|
||||
%pre %{dockerd_package}
|
||||
%sysusers_create_compat %{name} %{SOURCE2}
|
||||
|
||||
%post %{dockerd_package}
|
||||
%systemd_post %{name}.service
|
||||
|
||||
%preun %{dockerd_package}
|
||||
%systemd_preun %{name}.service
|
||||
|
||||
|
||||
# act_runner with rootless dockerd package
|
||||
%package %{dockerd_package_rootless}
|
||||
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_package}
|
||||
BuildRequires: systemd-rpm-macros
|
||||
%{?sysusers_requires_compat}
|
||||
|
||||
%description %{dockerd_package_rootless}
|
||||
%{common_description}
|
||||
Run gitea actions in non-root docker containers
|
||||
|
||||
%pre %{rootless_docker_user}
|
||||
%sysusers_create_package %{name} %{SOURCE3}
|
||||
%tmpfiles_create_package %{name} %{SOURCE4}
|
||||
%pre %{dockerd_package_rootless}
|
||||
%sysusers_create_compat %{name} %{SOURCE6}
|
||||
%dnl %tmpfiles_create_package %{name} %{SOURCE4}
|
||||
|
||||
%post %{rootless_docker_user}
|
||||
%systemd_user_post %{rootless_docker_user}.service %{name}.service
|
||||
loginctl enable-linger %{rootless_docker_user}
|
||||
cd ~%{rootless_docker_user}/act_runner
|
||||
%{act_runner_bin} register
|
||||
%{act_runner_bin} generate-config > config
|
||||
%post %{dockerd_package_rootless}
|
||||
%systemd_user_post %{name}.service
|
||||
# if ! grep -q "^$USERNAME_ESCAPED:\|^$(id -u):" /etc/subuid 2> /dev/null; then
|
||||
# # Add subuid entry for ${USERNAME}
|
||||
# echo "${USERNAME}:100000:65536" >> /etc/subuid
|
||||
# fi
|
||||
# if ! grep -q "^$USERNAME_ESCAPED:\|^$(id -u):" /etc/subgid 2> /dev/null; then
|
||||
# # Add subgid entry for ${USERNAME}
|
||||
# echo "${USERNAME}:100000:65536" >> /etc/subgid
|
||||
# fi
|
||||
loginctl enable-linger %{dockerd_package_rootless}
|
||||
echo Please read README.rootless-docker.md to finish the installation
|
||||
|
||||
%preun %{rootless_docker_user}
|
||||
%systemd_user_preun %{rootless_docker_user}.service %{name}.service
|
||||
%preun %{dockerd_package_rootless}
|
||||
loginctl disable-linger %{dockerd_package_rootless}
|
||||
%systemd_user_preun %{dockerd_package_rootless}.service %{name}.service
|
||||
|
||||
%prep
|
||||
%setup -q -n act_runner
|
||||
%{__cp} %{SOURCE8} %{SOURCE9} .
|
||||
|
||||
%build
|
||||
go build %{gobuild_baseflags} -o bin/%{act_runner_bin} %{goipath}
|
||||
|
||||
%install
|
||||
install -m 0755 -vd %{buildroot}%{_bindir}
|
||||
install -m 0755 -vp bin/* %{buildroot}%{_bindir}/
|
||||
install -m 0755 -vd %{buildroot}%{_userunitdir}/
|
||||
install -m 0644 -vp %{SOURCE1} %{SOURCE2} %{buildroot}%{_userunitdir}/
|
||||
install -D %{SOURCE3} %{buildroot}%{_sysusersdir}/%{rootless_docker_user}.conf
|
||||
install -D %{SOURCE4} %{buildroot}%{_tmpfilesdir}/%{rootless_docker_user}.conf
|
||||
install -m 0755 -vd %{buildroot}%{_unitdir}
|
||||
install -m 0755 -vd %{buildroot}%{_userunitdir}
|
||||
install -m 0755 -vd %{buildroot}%{_docdir}/%{name}
|
||||
|
||||
# The binary
|
||||
install -m 0755 -vp bin/* %{buildroot}%{_bindir}
|
||||
|
||||
# dockerd
|
||||
install -m 0644 -vp %{SOURCE1} %{buildroot}%{_unitdir}
|
||||
install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf
|
||||
%dnl install -D -m 0644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
||||
|
||||
# Rootless dockerd
|
||||
install -D -m 0644 -vp %{SOURCE4} %{buildroot}%{_userunitdir}/%{name}.conf
|
||||
install -D -m 0644 -vp %{SOURCE5} %{buildroot}%{_userunitdir}/%{name}-%{dockerd_package}.conf
|
||||
install -D -m 0644 %{SOURCE6} %{buildroot}%{_sysusersdir}/%{name}-%{rootless}.conf
|
||||
%dnl install -D -m 0644 %{SOURCE7} %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
||||
|
||||
%files
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
%{_bindir}/*
|
||||
|
||||
%files %{rootless_docker_user}
|
||||
%files %{dockerd_package}
|
||||
%license LICENSE
|
||||
%doc README-%{dockerd_package}.md
|
||||
%{_unitdir}/*
|
||||
%{_sysusersdir}/%{name}.conf
|
||||
|
||||
%files %{dockerd_package_rootless}
|
||||
%license LICENSE
|
||||
%doc README-%{rootless}-%{dockerd_package}.md
|
||||
%{_userunitdir}/*
|
||||
%{_sysusersdir}/%{rootless_docker_user}.conf
|
||||
%{_tmpfilesdir}/%{rootless_docker_user}.conf
|
||||
%{_sysusersdir}/%{name}-%{rootless}.conf
|
||||
%dnl %{_tmpfilesdir}/%{name}.conf
|
||||
|
||||
%changelog
|
||||
%autochangelog
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ~/act_runner
|
||||
act_runner register
|
||||
act_runner generate-config > config.yaml
|
||||
Reference in New Issue
Block a user