Skip to content

Commit 2ce3aa8

Browse files
authored
Create archlinux-builder.dockerfile
1 parent bac7d4c commit 2ce3aa8

File tree

1 file changed

+211
-0
lines changed

1 file changed

+211
-0
lines changed
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# syntax=docker/dockerfile:1
2+
#------------------------------------------------------------------------------------#
3+
#https://hub.docker.com/r/azathothas/archlinux-builder
4+
FROM azathothas/archlinux:latest
5+
#------------------------------------------------------------------------------------#
6+
##Base Deps
7+
RUN <<EOS
8+
#Base
9+
set +e
10+
pacman -Syu --noconfirm
11+
pacman base-devel bash bison ca-certificates coreutils curl dos2unix findutils gettext git gnupg gperf imagemagick jq less lzip lzlib moreutils micro nano ncdu pacutils p7zip rsync sudo texinfo tmux unzip util-linux wget xz zip --sync --noconfirm || true
12+
#RE
13+
pacman -Syu --noconfirm
14+
pacman base-devel bash bison ca-certificates coreutils curl dos2unix findutils gettext git gnupg gperf imagemagick jq less lzip lzlib moreutils micro nano ncdu pacutils p7zip rsync sudo texinfo tmux unzip util-linux wget xz zip --sync --needed --noconfirm || true
15+
#NetTools
16+
pacman inetutils iproute2 iputils net-tools openbsd-netcat --sync --needed --noconfirm || true
17+
setcap 'cap_net_raw+ep' "$(which ping)"
18+
#Python & Deps
19+
pacman patchelf python python-devtools python-distro python-lxml python-netifaces python-pypatchelf python-pip python-pipx python-pkgconfig python-xxhash scons sysfsutils virt-what --sync --needed --noconfirm || true
20+
#Test
21+
python --version 2>/dev/null ; python3 --version 2>/dev/null || true
22+
pip --version 2>/dev/null ; pip3 --version 2>/dev/null || true
23+
pipx --version 2>/dev/null || true
24+
EOS
25+
#------------------------------------------------------------------------------------#
26+
27+
#------------------------------------------------------------------------------------#
28+
##OS Settings
29+
RUN <<EOS
30+
#NameServers
31+
echo "nameserver 1.0.0.1" >> "/etc/resolv.conf"
32+
echo "nameserver 1.1.1.1" >> "/etc/resolv.conf"
33+
echo "nameserver 8.8.4.4" >> "/etc/resolv.conf"
34+
echo "nameserver 8.8.8.8" >> "/etc/resolv.conf"
35+
#Key-Verification
36+
#sed 's/^.*SigLevel\s*=.*$/SigLevel = Never/' -i "/etc/pacman.conf"
37+
#Update
38+
pacman -Syu --noconfirm || true
39+
EOS
40+
#------------------------------------------------------------------------------------#
41+
42+
#------------------------------------------------------------------------------------#
43+
##Create User + Setup Perms
44+
RUN <<EOS
45+
#Add runner
46+
useradd -m -s "/bin/bash" "runner"
47+
#Set password
48+
echo "runner:runneradmin" | chpasswd
49+
#Add runner to sudo
50+
usermod -aG "wheel" "runner"
51+
usermod -aG "wheel" "root"
52+
#Passwordless sudo for runner
53+
echo "%wheel ALL=(ALL) NOPASSWD: ALL" | tee -a "/etc/sudoers"
54+
compgen -u
55+
#Fix perms
56+
chmod 0440 "/etc/sudoers"
57+
visudo -c
58+
EOS
59+
##Change Default shell for runner to bash
60+
RUN <<EOS
61+
#Check current shell
62+
grep runner "/etc/passwd"
63+
#Change to bash
64+
usermod --shell "/bin/bash" "runner" 2>/dev/null
65+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/.bashrc" -o "/etc/bash.bashrc"
66+
dos2unix --quiet "/etc/bash.bashrc" 2>/dev/null
67+
ln --symbolic --force "/etc/bash.bashrc" "/home/runner/.bashrc" 2>/dev/null
68+
ln --symbolic --force "/etc/bash.bashrc" "/root/.bashrc" 2>/dev/null
69+
ln --symbolic --force "/etc/bash.bashrc" "/etc/bash/bashrc" 2>/dev/null
70+
#Recheck
71+
grep runner "/etc/passwd"
72+
EOS
73+
#------------------------------------------------------------------------------------#
74+
75+
#------------------------------------------------------------------------------------#
76+
##Addons
77+
RUN <<EOS
78+
#Addons
79+
#https://github.com/pkgforge/devscripts/blob/main/Linux/install_bins_curl.sh
80+
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh" -o "./tools.sh"
81+
dos2unix --quiet "./tools.sh" && chmod +x "./tools.sh"
82+
bash "./tools.sh" 2>/dev/null || true ; rm -rf "./tools.sh"
83+
##Appimage tools
84+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/go-appimagetool.no_strip" -o "/usr/local/bin/go-appimagetool" && chmod +x "/usr/local/bin/go-appimagetool"
85+
curl -qfsSL "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$(uname -m).AppImage" -o "/usr/local/bin/appimagetool" && chmod +x "/usr/local/bin/appimagetool"
86+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/linuxdeploy.no_strip" -o "/usr/local/bin/linuxdeploy" && chmod +x "/usr/local/bin/linuxdeploy"
87+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/mkappimage" -o "/usr/local/bin/mkappimage" && chmod +x "/usr/local/bin/mkappimage"
88+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/mksquashfs" -o "/usr/local/bin/mksquashfs" && chmod +x "/usr/local/bin/mksquashfs"
89+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/sqfscat" -o "/usr/local/bin/sqfscat" && chmod +x "/usr/local/bin/sqfscat"
90+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/sqfstar" -o "/usr/local/bin/sqfstar" && chmod +x "/usr/local/bin/sqfstar"
91+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/unsquashfs" -o "/usr/local/bin/unsquashfs" && chmod +x "/usr/local/bin/unsquashfs"
92+
EOS
93+
#------------------------------------------------------------------------------------#
94+
95+
#------------------------------------------------------------------------------------#
96+
##Build Tools
97+
RUN <<EOS
98+
#----------------------#
99+
##Main
100+
set +e
101+
pacman -Syu --noconfirm || true
102+
pacman aria2 autoconf autoconf-archive automake bazel bc binutils b3sum brotli busybox ccache clang cmake coreutils cython diffutils dos2unix findutils fontconfig gawk gcc gettext kernel-headers-musl jq libpcap libtool meson musl nasm polkit pkgconf rsync spirv-headers spirv-tools sqlite texinfo texi2html util-linux util-linux-libs wget libxslt xxhash yasm --sync --needed --noconfirm || true
103+
#Re
104+
pacman -Syu --noconfirm || true
105+
pacman aria2 autoconf autoconf-archive automake bazel bc binutils b3sum brotli busybox ccache clang cmake coreutils cython diffutils dos2unix findutils fontconfig gawk gcc gettext kernel-headers-musl jq libpcap libtool meson musl nasm polkit pkgconf rsync spirv-headers spirv-tools sqlite texinfo texi2html util-linux util-linux-libs wget libxslt xxhash yasm --sync --needed --noconfirm || true
106+
#----------------------#
107+
##Dockerc
108+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/dockerc" -o "/usr/bin/dockerc" && chmod +x "/usr/bin/dockerc"
109+
#----------------------#
110+
##Linux Headers
111+
if [ "$(uname -m)" == "aarch64" ]; then
112+
pacman -Syu --noconfirm && pacman linux-aarch64-headers --sync --needed --noconfirm || true
113+
elif [ "$(uname -m)" == "x86_64" ]; then
114+
pacman -Syu --noconfirm && pacman linux-headers --sync --needed --noconfirm || true
115+
else
116+
echo "[+]"
117+
fi
118+
#----------------------#
119+
##Install Meson & Ninja
120+
#sudo rm "/usr/bin/meson" "/usr/bin/ninja" 2>/dev/null
121+
pip install meson ninja --break-system-packages --upgrade --force-reinstall 2>/dev/null || true
122+
#----------------------#
123+
##musl
124+
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath "."
125+
git clone --filter "blob:none" --depth="1" "https://git.musl-libc.org/git/musl" && cd "./musl"
126+
unset AR CC CFLAGS CXX CPPFLAGS CXXFLAGS DLLTOOL HOST_CC HOST_CXX LDFLAGS OBJCOPY RANLIB
127+
make dest clean 2>/dev/null ; make clean 2>/dev/null
128+
bash "./configure" || true
129+
make --jobs="$(($(nproc)+1))" --keep-going install || true
130+
rm -rf "$(realpath .)" ; cd "${CWD}"
131+
ldconfig && ldconfig -p || true
132+
#----------------------#
133+
##staticx: https://github.com/JonathonReinhart/staticx/blob/main/.github/workflows/build-test.yml
134+
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath .
135+
#Switch to default: https://github.com/JonathonReinhart/staticx/pull/284
136+
git clone --filter "blob:none" "https://github.com/JonathonReinhart/staticx" --branch "add-type-checking" && cd "./staticx"
137+
#https://github.com/JonathonReinhart/staticx/blob/main/build.sh
138+
pip install -r "./requirements.txt" --break-system-packages --upgrade --force || true
139+
pacman -Syu --noconfirm
140+
export BOOTLOADER_CC="/usr/local/musl/bin/musl-gcc"
141+
rm -rf "./build" "./dist" "./scons_build" "./staticx/assets"
142+
python "./setup.py" sdist bdist_wheel
143+
find "dist/" -name "*.whl" | xargs -I {} sh -c 'newname=$(echo {} | sed "s/none-[^/]*\.whl$/none-any.whl/"); mv "{}" "$newname"'
144+
find "dist/" -name "*.whl" | xargs pip install --break-system-packages --upgrade --force || true
145+
staticx --version || pip install staticx --break-system-packages --force-reinstall --upgrade ; unset BOOTLOADER_CC
146+
rm -rf "$(realpath .)" ; cd "${CWD}"
147+
#----------------------#
148+
##pyinstaller
149+
pip install "git+https://github.com/pyinstaller/pyinstaller" --break-system-packages --force-reinstall --upgrade ; pyinstaller --version
150+
#----------------------#
151+
##golang
152+
#Installed later to ensure correct ENV
153+
#pacman -Syu --noconfirm && pacman go --sync --needed --noconfirm ; go version
154+
sudo -u "runner" bash -c \
155+
'
156+
sudo pacman -R go --noconfirm 2>/dev/null
157+
rm -rf "/usr/lib/go" 2>/dev/null
158+
pushd "$(mktemp -d)" >/dev/null
159+
echo "yes" | bash <(curl -qfsSL "https://git.io/go-installer")
160+
popd >/dev/null
161+
' || true
162+
echo 'export GOROOT="/home/runner/.go"' >> "/etc/bash.bashrc"
163+
echo 'export GOPATH="/home/runner/go"' >> "/etc/bash.bashrc"
164+
echo 'export PATH="${PATH}:${GOROOT}/bin:${GOPATH}/bin"' >> "/etc/bash.bashrc"
165+
#----------------------#
166+
##patchelf
167+
curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/patchelf" -o "/usr/bin/patchelf" && chmod +x "/usr/bin/patchelf"
168+
#----------------------#
169+
##Rust
170+
pacman -Syu --noconfirm && pacman rust --sync --needed --noconfirm ; cargo --version ; rustc --version || true
171+
#----------------------#
172+
EOS
173+
#------------------------------------------------------------------------------------#
174+
175+
#------------------------------------------------------------------------------------#
176+
##AUR Helpers
177+
RUN <<EOS
178+
#----------------------#
179+
#Paru:https://github.com/Morganamilo/paru
180+
sudo -u "runner" bash -c \
181+
'
182+
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath "."
183+
git clone --filter "blob:none" --depth="1" "https://aur.archlinux.org/paru-bin.git" && cd "./paru-bin"
184+
makepkg --install --syncdeps --cleanbuild --clean --force --noconfirm ; paru --version
185+
rm -rf "$(realpath .)" ; cd "${CWD}"
186+
' || true
187+
#----------------------#
188+
#Yay:https://github.com/Jguer/yay
189+
sudo -u "runner" bash -c \
190+
'
191+
export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath "."
192+
git clone --filter "blob:none" --depth="1" "https://aur.archlinux.org/yay.git" && cd "./yay"
193+
makepkg --install --syncdeps --cleanbuild --clean --force --noconfirm ; yay --version
194+
rm -rf "$(realpath .)" ; cd "${CWD}"
195+
' || true
196+
EOS
197+
#------------------------------------------------------------------------------------#
198+
199+
#------------------------------------------------------------------------------------#
200+
#Start
201+
RUN <<EOS
202+
#Locale
203+
echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/environment"
204+
echo "en_US.UTF-8 UTF-8" | tee -a "/etc/locale.gen"
205+
echo "LANG=en_US.UTF-8" | tee -a "/etc/locale.conf"
206+
locale-gen "en_US.UTF-8"
207+
EOS
208+
ENV LANG="en_US.UTF-8"
209+
ENV LANGUAGE="en_US:en"
210+
ENV LC_ALL="en_US.UTF-8"
211+
#------------------------------------------------------------------------------------#

0 commit comments

Comments
 (0)