|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +#------------------------------------------------------------------------------------# |
| 3 | +# DOCKER HUB URL : https://hub.docker.com/r/azathothas/ubuntu-builder |
| 4 | +FROM ubuntu:latest |
| 5 | +#FROM ubuntu:rolling |
| 6 | +#------------------------------------------------------------------------------------# |
| 7 | +##Base Deps |
| 8 | +ENV DEBIAN_FRONTEND="noninteractive" |
| 9 | +RUN <<EOS |
| 10 | + #Base |
| 11 | + apt-get update -y |
| 12 | + 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 sudo texinfo tmux tree unzip util-linux xz-utils wget zip" |
| 13 | + #Install |
| 14 | + apt-get update -y -qq |
| 15 | + for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done |
| 16 | + #Install_Re |
| 17 | + for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done |
| 18 | + #unminimize : https://wiki.ubuntu.com/Minimal |
| 19 | + yes | unminimize |
| 20 | + #Python |
| 21 | + apt-get install python3 -y |
| 22 | + #Test |
| 23 | + python --version 2>/dev/null ; python3 --version 2>/dev/null |
| 24 | + #Install pip: |
| 25 | + #python3 -m ensurepip --upgrade ; pip3 --version |
| 26 | + #curl -qfsSL "https://bootstrap.pypa.io/get-pip.py" -o "$SYSTMP/get-pip.py" && python3 "$SYSTMP/get-pip.py" |
| 27 | + packages="libxslt-dev lm-sensors pciutils procps python3-distro python-dev-is-python3 python3-lxml python3-netifaces python3-pip python3-venv sysfsutils virt-what" |
| 28 | + for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done |
| 29 | + pip install --break-system-packages --upgrade pip || pip install --upgrade pip |
| 30 | + #Misc |
| 31 | + pip install ansi2txt --break-system-packages --force-reinstall --upgrade |
| 32 | + #pipx |
| 33 | + pip install pipx --upgrade 2>/dev/null |
| 34 | + pip install pipx --upgrade --break-system-packages 2>/dev/null |
| 35 | +EOS |
| 36 | +#------------------------------------------------------------------------------------# |
| 37 | +##Systemd installation |
| 38 | +RUN <<EOS |
| 39 | + #SystemD |
| 40 | + apt-get update -y |
| 41 | + packages="dbus iptables iproute2 libsystemd0 kmod systemd systemd-sysv udev" |
| 42 | + for pkg in $packages; do apt install -y --ignore-missing "$pkg"; done |
| 43 | + #Housekeeping |
| 44 | + apt-get clean -y |
| 45 | + rm -rf "/lib/systemd/system/getty.target" 2>/dev/null |
| 46 | + rm -rf "/lib/systemd/system/systemd"*udev* 2>/dev/null |
| 47 | + rm -rf "/usr/share/doc/"* 2>/dev/null |
| 48 | + rm -rf "/usr/share/local/"* 2>/dev/null |
| 49 | + rm -rf "/usr/share/man/"* 2>/dev/null |
| 50 | + rm -rf "/var/cache/debconf/"* 2>/dev/null |
| 51 | + rm -rf "/var/lib/apt/lists/"* 2>/dev/null |
| 52 | + rm -rf "/var/log/"* 2>/dev/null |
| 53 | + rm -rf "/var/tmp/"* 2>/dev/null |
| 54 | + rm -rf "/tmp/"* 2>/dev/null |
| 55 | +EOS |
| 56 | +# Make use of stopsignal (instead of sigterm) to stop systemd containers. |
| 57 | +STOPSIGNAL SIGRTMIN+3 |
| 58 | +#------------------------------------------------------------------------------------# |
| 59 | + |
| 60 | +#------------------------------------------------------------------------------------# |
| 61 | +##Create User + Setup Perms |
| 62 | +RUN <<EOS |
| 63 | + #Add runner |
| 64 | + useradd --create-home "runner" |
| 65 | + #Set password |
| 66 | + echo "runner:runneradmin" | chpasswd |
| 67 | + #Add runner to sudo |
| 68 | + usermod -aG "sudo" "runner" |
| 69 | + usermod -aG "sudo" "root" |
| 70 | + #Passwordless for runner |
| 71 | + echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" >> "/etc/sudoers" |
| 72 | + #Remove preconfigured admin user |
| 73 | + userdel -r "admin" 2>/dev/null || true |
| 74 | +EOS |
| 75 | +##Change Default shell for runner to bash |
| 76 | +RUN <<EOS |
| 77 | + #Check current shell |
| 78 | + grep runner "/etc/passwd" |
| 79 | + #Change to bash |
| 80 | + usermod --shell "/bin/bash" "runner" 2>/dev/null |
| 81 | + curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/.bashrc" -o "/etc/bash.bashrc" |
| 82 | + dos2unix --quiet "/etc/bash.bashrc" 2>/dev/null |
| 83 | + ln --symbolic --force "/etc/bash.bashrc" "/home/runner/.bashrc" 2>/dev/null |
| 84 | + ln --symbolic --force "/etc/bash.bashrc" "/root/.bashrc" 2>/dev/null |
| 85 | + ln --symbolic --force "/etc/bash.bashrc" "/etc/bash/bashrc" 2>/dev/null |
| 86 | + #Recheck |
| 87 | + grep runner "/etc/passwd" |
| 88 | +EOS |
| 89 | +#------------------------------------------------------------------------------------# |
| 90 | + |
| 91 | +#------------------------------------------------------------------------------------# |
| 92 | +##Addons |
| 93 | +RUN <<EOS |
| 94 | + #Addons |
| 95 | + #https://github.com/pkgforge/devscripts/blob/main/Linux/install_bins_curl.sh |
| 96 | + curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh" -o "./tools.sh" |
| 97 | + dos2unix --quiet "./tools.sh" && chmod +x "./tools.sh" |
| 98 | + bash "./tools.sh" 2>/dev/null || true ; rm -rf "./tools.sh" |
| 99 | + ##Appimage tools |
| 100 | + 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" |
| 101 | + 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" |
| 102 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/linuxdeploy.no_strip" -o "/usr/local/bin/linuxdeploy" && chmod +x "/usr/local/bin/linuxdeploy" |
| 103 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/mkappimage" -o "/usr/local/bin/mkappimage" && chmod +x "/usr/local/bin/mkappimage" |
| 104 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/mksquashfs" -o "/usr/local/bin/mksquashfs" && chmod +x "/usr/local/bin/mksquashfs" |
| 105 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/sqfscat" -o "/usr/local/bin/sqfscat" && chmod +x "/usr/local/bin/sqfscat" |
| 106 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/sqfstar" -o "/usr/local/bin/sqfstar" && chmod +x "/usr/local/bin/sqfstar" |
| 107 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/Baseutils/squashfstools/unsquashfs" -o "/usr/local/bin/unsquashfs" && chmod +x "/usr/local/bin/unsquashfs" |
| 108 | +EOS |
| 109 | +#------------------------------------------------------------------------------------# |
| 110 | + |
| 111 | +#------------------------------------------------------------------------------------# |
| 112 | +##Build Tools |
| 113 | +RUN <<EOS |
| 114 | + #----------------------# |
| 115 | + #Main |
| 116 | + set +e |
| 117 | + packages="apt-transport-https apt-utils aria2 autoconf automake autopoint bc binutils bison b3sum build-essential byacc ca-certificates ccache clang cmake coreutils desktop-file-utils devscripts diffutils dnsutils dos2unix flex file findutils gawk git-lfs gnupg2 imagemagick lzip liblz-dev librust-lzma-sys-dev lzma lzma-dev jq libsqlite3-dev libtool libtool-bin make moreutils musl musl-dev musl-tools patch patchelf pkg-config python3-pip python3-venv p7zip-full qemu-user-static rsync scons software-properties-common sqlite3 sqlite3-pcre sqlite3-tools texinfo tree util-linux wget xz-utils zsync" |
| 118 | + #Install |
| 119 | + apt-get update -y -qq |
| 120 | + for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done |
| 121 | + #Install_Re |
| 122 | + for pkg in $packages; do DEBIAN_FRONTEND="noninteractive" apt install -y --ignore-missing "$pkg"; done |
| 123 | + #----------------------# |
| 124 | + #Dockerc |
| 125 | + curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)/dockerc" -o "/usr/bin/dockerc" && chmod +x "/usr/bin/dockerc" |
| 126 | + #----------------------# |
| 127 | + #Install Meson & Ninja |
| 128 | + #rm "/usr/bin/meson" "/usr/bin/ninja" 2>/dev/null |
| 129 | + pip install meson ninja --upgrade 2>/dev/null |
| 130 | + pip install meson ninja --break-system-packages --upgrade --force-reinstall 2>/dev/null |
| 131 | + #----------------------# |
| 132 | + #libpcap |
| 133 | + apt install libpcap-dev pcaputils -y 2>/dev/null |
| 134 | + #----------------------# |
| 135 | + #libsqlite3 |
| 136 | + apt-get install libsqlite3-dev sqlite3 sqlite3-pcre sqlite3-tools -y 2>/dev/null |
| 137 | + #----------------------# |
| 138 | + #lzma |
| 139 | + apt-get install liblz-dev librust-lzma-sys-dev lzma lzma-dev -y |
| 140 | + #----------------------# |
| 141 | + #staticx: https://github.com/JonathonReinhart/staticx/blob/main/.github/workflows/build-test.yml |
| 142 | + export CWD="$(realpath .)" ; cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath . |
| 143 | + #Switch to default: https://github.com/JonathonReinhart/staticx/pull/284 |
| 144 | + git clone --filter "blob:none" "https://github.com/JonathonReinhart/staticx" --branch "add-type-checking" && cd "./staticx" |
| 145 | + #https://github.com/JonathonReinhart/staticx/blob/main/build.sh |
| 146 | + pip install -r "./requirements.txt" --break-system-packages --upgrade --force |
| 147 | + apt-get update -y |
| 148 | + apt-get install -y busybox musl-tools scons |
| 149 | + export BOOTLOADER_CC="musl-gcc" |
| 150 | + rm -rf "./build" "./dist" "./scons_build" "./staticx/assets" |
| 151 | + python "./setup.py" sdist bdist_wheel |
| 152 | + find "dist/" -name "*.whl" | xargs -I {} sh -c 'newname=$(echo {} | sed "s/none-[^/]*\.whl$/none-any.whl/"); mv "{}" "$newname"' |
| 153 | + find "dist/" -name "*.whl" | xargs pip install --break-system-packages --upgrade --force |
| 154 | + staticx --version || pip install staticx --break-system-packages --force-reinstall --upgrade ; unset BOOTLOADER_CC |
| 155 | + rm -rf "$(realpath .)" ; cd "${CWD}" |
| 156 | + #----------------------# |
| 157 | + #pyinstaller |
| 158 | + pip install "git+https://github.com/pyinstaller/pyinstaller" --break-system-packages --force-reinstall --upgrade ; pyinstaller --version |
| 159 | + #----------------------# |
| 160 | + #golang |
| 161 | + cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath . |
| 162 | + curl -qfsSL "https://git.io/go-installer" -o "./install.sh" |
| 163 | + dos2unix --quiet "./install.sh" && chmod +x "./install.sh" |
| 164 | + echo "yes" | bash "./install.sh" 2>/dev/null || true |
| 165 | + rm -rf "$(realpath .)" ; cd "${CWD}" |
| 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 | + cd "$(mktemp -d)" >/dev/null 2>&1 ; realpath . |
| 171 | + curl -qfsSL "https://sh.rustup.rs" -o "./install.sh" |
| 172 | + dos2unix --quiet "./install.sh" && chmod +x "./install.sh" |
| 173 | + bash "./install.sh" -y 2>/dev/null || true |
| 174 | + rm -rf "$(realpath .)" ; cd "${CWD}" |
| 175 | + #----------------------# |
| 176 | +EOS |
| 177 | +#------------------------------------------------------------------------------------# |
| 178 | + |
| 179 | +#------------------------------------------------------------------------------------# |
| 180 | +#Start |
| 181 | +RUN <<EOS |
| 182 | + #Locale |
| 183 | + echo "LC_ALL=en_US.UTF-8" | tee -a "/etc/environment" |
| 184 | + echo "en_US.UTF-8 UTF-8" | tee -a "/etc/locale.gen" |
| 185 | + echo "LANG=en_US.UTF-8" | tee -a "/etc/locale.conf" |
| 186 | + locale-gen "en_US.UTF-8" |
| 187 | + #Dialog |
| 188 | + echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections |
| 189 | + debconf-show debconf |
| 190 | +EOS |
| 191 | +ENV DEBIAN_FRONTEND="noninteractive" |
| 192 | +ENV LANG="en_US.UTF-8" |
| 193 | +ENV LANGUAGE="en_US:en" |
| 194 | +ENV LC_ALL="en_US.UTF-8" |
| 195 | +ENV PATH="$HOME/bin:$HOME/.cargo/bin:$HOME/.cargo/env:$HOME/.go/bin:$HOME/go/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$HOME/.local/bin:$HOME/miniconda3/bin:$HOME/miniconda3/condabin:/usr/local/zig:/usr/local/zig/lib:/usr/local/zig/lib/include:/usr/local/musl/bin:/usr/local/musl/lib:/usr/local/musl/include:$PATH" |
| 196 | +#------------------------------------------------------------------------------------# |
0 commit comments