Skip to content

Commit ee70145

Browse files
committed
add
1 parent abda76c commit ee70145

File tree

5 files changed

+270
-4
lines changed

5 files changed

+270
-4
lines changed

Github/Runners/aarch64-ubuntu.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ RUN <<EOS
123123
sed -i 's/ulimit -Hn/# ulimit -Hn/g' "/etc/init.d/docker"
124124
#Install Additional Deps
125125
packages="btrfs-progs fuse-overlayfs fuse3 kmod libfuse3-dev zfs-dkms"
126-
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
126+
for pkg in $packages; do apt install -y --ignore-missing "$pkg" || true; done
127+
true
127128
EOS
128129
#------------------------------------------------------------------------------------#
129130

Github/Runners/manage_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,4 @@ trap 'remove_runner; exit 143' SIGTERM
203203
#------------------------------------------------------------------------------------#
204204
#Run with Initial ARGs
205205
"/runner-init/run.sh" "$*"
206-
#------------------------------------------------------------------------------------#
206+
#------------------------------------------------------------------------------------#
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
# syntax=docker/dockerfile:1
2+
#------------------------------------------------------------------------------------#
3+
# Based on :: https://github.com/pkgforge/devscripts/blob/main/Github/Runners/ubuntu-systemd-base.dockerfile
4+
# Preconfigured with: Systemd + SSHD + Docker
5+
# URL: https://hub.docker.com/r/pkgforge/gh-runner-riscv64-ubuntu
6+
FROM ubuntu:latest
7+
#------------------------------------------------------------------------------------#
8+
##Base Deps
9+
ENV DEBIAN_FRONTEND="noninteractive"
10+
RUN <<EOS
11+
#Base
12+
export DEBIAN_FRONTEND="noninteractive"
13+
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
14+
packages="apt-transport-https apt-utils bash ca-certificates coreutils curl dos2unix fdupes findutils git gnupg2 imagemagick jq locales locate moreutils nano ncdu p7zip-full rename rsync software-properties-common texinfo sudo tmux unzip util-linux xz-utils wget zip"
15+
#Install
16+
apt update -y -qq
17+
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
18+
#Install_Re
19+
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
20+
#unminimize : https://wiki.ubuntu.com/Minimal
21+
yes | unminimize
22+
#Python
23+
apt install python3 -y
24+
#Test
25+
python --version 2>/dev/null ; python3 --version 2>/dev/null
26+
#Install pip:
27+
#python3 -m ensurepip --upgrade ; pip3 --version
28+
#curl -qfsSL "https://bootstrap.pypa.io/get-pip.py" -o "$SYSTMP/get-pip.py" && python3 "$SYSTMP/get-pip.py"
29+
packages="libxslt-dev lm-sensors pciutils procps python3-distro python-dev-is-python3 python3-lxml python3-netifaces python3-pip python3-venv sysfsutils virt-what"
30+
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
31+
pip install --break-system-packages --upgrade pip || pip install --upgrade pip
32+
#Misc
33+
pip install ansi2txt --break-system-packages --force-reinstall --upgrade
34+
#pipx
35+
pip install pipx --upgrade 2>/dev/null
36+
pip install pipx --upgrade --break-system-packages 2>/dev/null
37+
EOS
38+
#------------------------------------------------------------------------------------#
39+
##Systemd installation
40+
RUN <<EOS
41+
#SystemD
42+
apt update -y
43+
packages="dbus iptables iproute2 libsystemd0 kmod systemd systemd-sysv udev"
44+
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
45+
##Prevents journald from reading kernel messages from /dev/kmsg
46+
# echo "ReadKMsg=no" >> "/etc/systemd/journald.conf"
47+
#Disable systemd services/units that are unnecessary within a container.
48+
#systemctl mask "systemd-udevd.service"
49+
#systemctl mask "systemd-udevd-kernel.socket"
50+
#systemctl mask "systemd-udevd-control.socket"
51+
#systemctl mask "systemd-modules-load.service"
52+
#systemctl mask "sys-kernel-debug.mount"
53+
#systemctl mask "sys-kernel-tracing.mount"
54+
#Housekeeping
55+
apt clean -y
56+
rm -rf "/lib/systemd/system/getty.target" 2>/dev/null
57+
rm -rf "/lib/systemd/system/systemd"*udev* 2>/dev/null
58+
rm -rf "/usr/share/doc/"* 2>/dev/null
59+
rm -rf "/usr/share/local/"* 2>/dev/null
60+
rm -rf "/usr/share/man/"* 2>/dev/null
61+
rm -rf "/var/cache/debconf/"* 2>/dev/null
62+
rm -rf "/var/lib/apt/lists/"* 2>/dev/null
63+
rm -rf "/var/log/"* 2>/dev/null
64+
rm -rf "/var/tmp/"* 2>/dev/null
65+
rm -rf "/tmp/"* 2>/dev/null
66+
EOS
67+
# Make use of stopsignal (instead of sigterm) to stop systemd containers.
68+
STOPSIGNAL SIGRTMIN+3
69+
#------------------------------------------------------------------------------------#
70+
71+
#------------------------------------------------------------------------------------#
72+
##Create User + Setup Perms
73+
RUN <<EOS
74+
#Add runner
75+
useradd --create-home "runner"
76+
#Set password
77+
echo "runner:runneradmin" | chpasswd
78+
#Add runner to sudo
79+
usermod -aG "sudo" "runner"
80+
usermod -aG "sudo" "root"
81+
#Passwordless sudo for runner
82+
echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" >> "/etc/sudoers"
83+
EOS
84+
##Change Default shell for runner to bash
85+
RUN <<EOS
86+
#Check current shell
87+
grep runner "/etc/passwd"
88+
#Change to bash
89+
usermod --shell "/bin/bash" "runner" 2>/dev/null
90+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/.bashrc" -o "/etc/bash.bashrc"
91+
dos2unix --quiet "/etc/bash.bashrc" 2>/dev/null
92+
ln --symbolic --force "/etc/bash.bashrc" "/home/runner/.bashrc" 2>/dev/null
93+
ln --symbolic --force "/etc/bash.bashrc" "/root/.bashrc" 2>/dev/null
94+
ln --symbolic --force "/etc/bash.bashrc" "/etc/bash/bashrc" 2>/dev/null
95+
#Recheck
96+
grep runner "/etc/passwd"
97+
EOS
98+
#------------------------------------------------------------------------------------#
99+
100+
#------------------------------------------------------------------------------------#
101+
##Install Docker
102+
RUN <<EOS
103+
#Install Docker
104+
rm -rf "/var/lib/apt/lists/"*
105+
cd "$(mktemp -d)" >/dev/null 2>&1
106+
curl -qfsSL "https://get.docker.com" -o "./get-docker.sh" && sh "./get-docker.sh"
107+
cd - >/dev/null 2>&1
108+
#Add runner to docker
109+
usermod -aG "docker" "runner"
110+
#Add Docker Completions
111+
curl -qfsSL "https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker" > "/etc/bash_completion.d/docker.sh"
112+
#Confiure Docker Opts
113+
#Remove Hardlimit
114+
sed -i 's/ulimit -Hn/# ulimit -Hn/g' "/etc/init.d/docker"
115+
#Install Additional Deps
116+
packages="btrfs-progs fuse-overlayfs fuse3 kmod libfuse3-dev"
117+
for pkg in $packages; do apt install -y --ignore-missing "$pkg" || true; done
118+
true
119+
EOS
120+
#------------------------------------------------------------------------------------#
121+
122+
#------------------------------------------------------------------------------------#
123+
##Addons
124+
RUN <<EOS
125+
##Addons
126+
#https://github.com/pkgforge/devscripts/blob/main/Linux/install_bins_curl.sh
127+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh" -o "./tools.sh"
128+
dos2unix --quiet "./tools.sh" && chmod +x "./tools.sh"
129+
bash "./tools.sh" 2>/dev/null || true ; rm -rf "./tools.sh"
130+
EOS
131+
#------------------------------------------------------------------------------------#
132+
133+
#------------------------------------------------------------------------------------#
134+
##Build Tools
135+
RUN <<EOS
136+
apt update -y
137+
packages="aria2 automake bc binutils b3sum build-essential ca-certificates ccache diffutils dos2unix findutils gawk lzip jq libtool libtool-bin make musl musl-dev musl-tools p7zip-full rsync texinfo wget xz-utils"
138+
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
139+
apt install python3 -y
140+
EOS
141+
#------------------------------------------------------------------------------------#
142+
143+
#------------------------------------------------------------------------------------#
144+
##Download Runner Script
145+
# https://github.com/dkurt/github_actions_riscv
146+
WORKDIR /runner
147+
RUN <<EOS
148+
#Setup Dotnet: https://github.com/dkurt/dotnet_riscv/releases/latest
149+
wget --quiet --show-progress "https://github.com/dkurt/dotnet_riscv/releases/latest/download/dotnet-sdk-9.0.100-linux-riscv64-gcc-ubuntu-24.04.tar.gz" -O "./dotnet.tar.gz"
150+
if [ ! -f "./dotnet.tar.gz" ]; then
151+
exit 1
152+
else
153+
mkdir -pv "/opt/dotnet"
154+
tar -xzf "./dotnet.tar.gz" -C "/opt/dotnet"
155+
if [ ! -f "/opt/dotnet/dotnet" ]; then
156+
exit 1
157+
else
158+
ln -fsv "/opt/dotnet/dotnet" "/usr/local/bin/dotnet"
159+
rm -rf "./dotnet.tar.gz"
160+
fi
161+
fi
162+
#Setup GH Runner (riscv64): https://github.com/dkurt/github_actions_riscv/releases/latest
163+
wget --quiet --show-progress "https://github.com/pkgforge/devscripts/releases/download/gh-riscv64-Linux/runner.tar.gz" -O "./runner.tar.gz"
164+
if [ ! -f "./runner.tar.gz" ]; then
165+
exit 1
166+
fi
167+
#Untar
168+
mkdir -p "/runner-init"
169+
tar -xzf "./runner.tar.gz" -C "/runner-init" && rm "./runner.tar.gz"
170+
#Dos2unix
171+
find "/runner-init" -type f -exec dos2unix --quiet {} \; 2>/dev/null || true
172+
#Run Install
173+
chmod +x "/runner-init/bin/installdependencies.sh" && bash "/runner-init/bin/installdependencies.sh"
174+
#Remove cache
175+
rm -rf "/var/lib/apt/lists/"* 2>/dev/null
176+
EOS
177+
#Copy Manager script
178+
COPY "./manager.sh" "/usr/local/bin/manager.sh"
179+
RUN chmod +x "/usr/local/bin/manager.sh"
180+
#------------------------------------------------------------------------------------#
181+
182+
#------------------------------------------------------------------------------------#
183+
##Display & x11 :: https://github.com/puppeteer/puppeteer/issues/8148
184+
RUN <<EOS
185+
#x11 & display server
186+
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
187+
apt update -y
188+
packages="dbus-x11 fonts-ipafont-gothic fonts-freefont-ttf gtk2-engines-pixbuf imagemagick libxss1 xauth xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable x11-apps xorg xvfb"
189+
for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done
190+
#Re
191+
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
192+
apt update -y
193+
packages="dbus-x11 fonts-ipafont-gothic fonts-freefont-ttf gtk2-engines-pixbuf imagemagick libxss1 xauth xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable x11-apps xorg xvfb"
194+
for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done
195+
#Configure
196+
touch "/root/.Xauthority"
197+
sudo -u "runner" touch "/home/runner/.Xauthority"
198+
#To start: (-ac --> disable access control restrictions)
199+
#Xvfb -ac ":0" &
200+
# export DISPLAY=":0" && google-chrome
201+
EOS
202+
#------------------------------------------------------------------------------------#
203+
204+
#------------------------------------------------------------------------------------#
205+
##This is no longer needed because replaced docker with podman
206+
##Docker systemctl https://github.com/gdraheim/docker-systemctl-replacement
207+
RUN <<EOS
208+
#systemctl
209+
#System has not been booted with systemd as init system (PID 1). Can't operate.
210+
#Failed to connect to bus: Host is down
211+
#Replace with patched
212+
apt install python3 -y
213+
# curl -qfsSL "https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py" -o "$(which systemctl)"
214+
mkdir -p "/var/run/dbus" ; dbus-daemon --config-file="/usr/share/dbus-1/system.conf" --print-address
215+
EOS
216+
#------------------------------------------------------------------------------------#
217+
218+
#------------------------------------------------------------------------------------#
219+
##Enable SSH & SSH Service
220+
RUN <<EOS
221+
##Install SSH
222+
set +e
223+
apt update -y && apt install openssh-server ssh -y
224+
#Config
225+
mkdir -p "/run/sshd" ; mkdir -p "/etc/ssh" ; touch "/var/log/auth.log" "/var/log/btmp" 2>/dev/null || true
226+
mkdir -p "/root/.ssh" ; chown "root:root" "/root/.ssh"
227+
#touch "/etc/ssh/authorized_keys" "/root/.ssh/authorized_keys" "/root/.ssh/config" "/root/.ssh/known_hosts"
228+
mkdir -p "/home/runner/.ssh" ; chown "runner:runner" "/home/runner/.ssh"
229+
touch "/etc/ssh/authorized_keys" "/home/runner/.ssh/authorized_keys" "/home/runner/.ssh/config" "/home/runner/.ssh/known_hosts"
230+
#Generate-Keys
231+
echo "yes" | ssh-keygen -N "" -t "ecdsa" -b 521 -f "/etc/ssh/ssh_host_ecdsa_key"
232+
#cp "/etc/ssh/ssh_host_ecdsa_key" "/home/runner/.ssh/id_ecdsa" ; cp "/etc/ssh/ssh_host_ecdsa_key" "/root/.ssh/id_ecdsa"
233+
#cp "/etc/ssh/ssh_host_ecdsa_key.pub" "/home/runner/.ssh/id_ecdsa.pub" ; cp "/etc/ssh/ssh_host_ecdsa_key.pub" "root/.ssh/id_ecdsa.pub"
234+
echo "yes" | ssh-keygen -N "" -t "ed25519" -f "/etc/ssh/ssh_host_ed25519_key"
235+
#cp "/etc/ssh/ssh_host_ed25519_key" "/home/runner/.ssh/id_ed25519" ; cp "/etc/ssh/ssh_host_ed25519_key" "/root/.ssh/id_ed25519"
236+
#cp "/etc/ssh/ssh_host_ed25519_key.pub" "/home/runner/.ssh/id_ed25519.pub" ; cp "/etc/ssh/ssh_host_ed25519_key.pub" "/root/.ssh/id_ed25519.pub"
237+
echo "yes" | ssh-keygen -N "" -t "rsa" -b 4096 -f "/etc/ssh/ssh_host_rsa_key"
238+
#cp "/etc/ssh/ssh_host_rsa_key" "/home/runner/.ssh/id_rsa" ; cp "/etc/ssh/ssh_host_rsa_key" "/root/.ssh/id_rsa"
239+
#cp "/etc/ssh/ssh_host_rsa_key.pub" "/home/runner/.ssh/id_rsa.pub" ; cp "/etc/ssh/ssh_host_rsa_key.pub" "/root/.ssh/id_rsa.pub"
240+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/sshd_config_passwordless" -o "/etc/ssh/sshd_config"
241+
#Perms
242+
chown -R "root:root" "/root/.ssh" ; chown "root:root" "/etc/ssh/authorized_keys" ; chmod 644 "/etc/ssh/authorized_keys"
243+
chown -R "runner:runner" "/home/runner/.ssh"
244+
sudo -u "runner" chmod 750 -R "/home/runner"
245+
sudo -u "runner" chmod 700 -R "/home/runner/.ssh"
246+
sudo -u "runner" chmod 600 "/home/runner/.ssh/authorized_keys" "/home/runner/.ssh/config"
247+
sudo -u "runner" chmod 644 "/home/runner/.ssh/known_hosts"
248+
systemctl enable ssh --now 2>/dev/null || true
249+
EOS
250+
EXPOSE 22
251+
#------------------------------------------------------------------------------------#
252+
253+
#------------------------------------------------------------------------------------#
254+
#Start
255+
RUN <<EOS
256+
locale-gen "en_US.UTF-8"
257+
EOS
258+
ENV GIT_ASKPASS="/bin/echo"
259+
ENV GIT_TERMINAL_PROMPT="0"
260+
ENV LANG="en_US.UTF-8"
261+
ENV LANGUAGE="en_US:en"
262+
ENV LC_ALL="en_US.UTF-8"
263+
ENTRYPOINT ["/sbin/init"]
264+
#------------------------------------------------------------------------------------#

Github/Runners/ubuntu-systemd-base.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ RUN <<EOS
121121
#Remove Hardlimit
122122
sed -i 's/ulimit -Hn/# ulimit -Hn/g' "/etc/init.d/docker"
123123
#Install Additional Deps
124-
packages="btrfs-progs fuse-overlayfs fuse3 kmod libfuse3-dev zfs-dkms"
124+
packages="btrfs-progs fuse-overlayfs fuse3 kmod libfuse3-dev"
125125
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
126126
EOS
127127
#------------------------------------------------------------------------------------#

Github/Runners/x86_64-ubuntu.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ RUN <<EOS
123123
sed -i 's/ulimit -Hn/# ulimit -Hn/g' "/etc/init.d/docker"
124124
#Install Additional Deps
125125
packages="btrfs-progs fuse-overlayfs fuse3 kmod libfuse3-dev zfs-dkms"
126-
for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done
126+
for pkg in $packages; do apt install -y --ignore-missing "$pkg" || true; done
127+
true
127128
EOS
128129
#------------------------------------------------------------------------------------#
129130

0 commit comments

Comments
 (0)