diff --git a/Dockerfile.almalinux b/Dockerfile.almalinux index 892da18..07982e3 100644 --- a/Dockerfile.almalinux +++ b/Dockerfile.almalinux @@ -1,6 +1,6 @@ FROM almalinux:9 -ARG RUNNERREPO="https://github.com/actions/runner" RUNNERPATCH SDK ARCH +ARG RUNNERREPO="https://github.com/actions/runner" RUNNERPATCH SDK ARCH BTOOLS RUN dnf update -y -q && \ dnf install -y -q wget git which langpacks-en glibc-all-langpacks sudo @@ -39,9 +39,20 @@ RUN mkdir -p /opt/runner && \ chown -R almalinux:almalinux /opt/runner && \ su -c "/opt/runner/config.sh --version" almalinux -RUN dnf install -y -q cmake make automake autoconf m4 gcc gcc-c++ libtool epel-release +RUN dnf install -y -q cmake make automake autoconf m4 gcc gcc-c++ libtool epel-release zlib-devel libffi-devel libyaml -RUN rm -rf /tmp/runner /var/cache/dnf/* /tmp/runner.patch && \ +COPY build-files/install-python.sh /tmp +COPY build-files/install-ruby.sh /tmp + +RUN if [ "${BTOOLS}" -eq 1 ]; then \ + chmod +x /tmp/install-python.sh && \ + /tmp/install-python.sh && \ + chmod +x /tmp/install-ruby.sh && \ + /tmp/install-ruby.sh && \ + chown -R almalinux:almalinux /opt/runner; \ + fi + +RUN rm -rf /tmp/runner /var/cache/dnf/* /tmp/runner.patch /tmp/install-python.sh /tmp/install-ruby.sh && \ dnf clean all USER almalinux diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 343faeb..c5c0b89 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -1,6 +1,6 @@ FROM ubuntu:22.04 -ARG RUNNERREPO="https://github.com/actions/runner" RUNNERPATCH SDK ARCH +ARG RUNNERREPO="https://github.com/actions/runner" RUNNERPATCH SDK ARCH BTOOLS ENV DEBIAN_FRONTEND=noninteractive @@ -47,9 +47,20 @@ RUN mkdir -p /opt/runner && \ chown -R ubuntu:ubuntu /opt/runner && \ su -c "/opt/runner/config.sh --version" ubuntu -RUN apt-get -qq -y install cmake make automake autoconf m4 gcc-12-base libtool +RUN apt-get -qq -y install cmake make automake autoconf m4 gcc-12-base libtool zlib1g-dev libffi-dev libyaml-dev -RUN rm -rf /tmp/runner /tmp/runner.patch /tmp/convert-rpm.sh +COPY build-files/install-python.sh /tmp +COPY build-files/install-ruby.sh /tmp + +RUN if [ "${BTOOLS}" -eq 1 ]; then \ + chmod +x /tmp/install-python.sh && \ + /tmp/install-python.sh && \ + chmod +x /tmp/install-ruby.sh && \ + /tmp/install-ruby.sh && \ + chown -R ubuntu:ubuntu /opt/runner; \ + fi + +RUN rm -rf /tmp/runner /tmp/runner.patch /tmp/convert-rpm.sh /tmp/install-python.sh /tmp/install-ruby.sh USER ubuntu diff --git a/build-files/build-image.sh b/build-files/build-image.sh index d5f9567..8e8c1a6 100755 --- a/build-files/build-image.sh +++ b/build-files/build-image.sh @@ -7,6 +7,9 @@ update_fresh_container() { if [ $? -ne 0 ]; then exit 32 fi + if [ ${BTOOLS} -eq 1 ]; then + sudo DEBIAN_FRONTEND=noninteractive apt-get install wget gcc make zlib1g-dev libffi-dev libtool libyaml-dev -y + fi sudo apt autoclean echo "Initializing LXD environment" @@ -124,6 +127,22 @@ install_runner() { return $? } +install_python() { + echo "Installing Python" + chmod +x /home/ubuntu/install-python.sh + sudo /home/ubuntu/install-python.sh + sudo chown ubuntu:ubuntu -R /opt/runner + return $? +} + +install_ruby() { + echo "Installing Ruby" + chmod +x /home/ubuntu/install-ruby.sh + sudo /home/ubuntu/install-ruby.sh + sudo chown ubuntu:ubuntu -R /opt/runner + return $? +} + cleanup() { rm -rf /home/ubuntu/build-image.sh /home/ubuntu/runner-${ARCH}.patch \ /tmp/runner /tmp/preseed-yaml @@ -142,6 +161,11 @@ run() { if [ ${RC} -eq 0 ]; then install_runner RC=$? + if [ ${BTOOLS} -eq 1 ]; then + install_python + install_ruby + RC=$? + fi fi fi fi @@ -153,7 +177,8 @@ export HOME=/home/ubuntu ARCH=`uname -m` SDK="" RUNNERREPO="https://github.com/actions/runner" -while getopts "a:s:" opt +BTOOLS="0" +while getopts "a:s:t:" opt do case ${opt} in a) @@ -162,6 +187,9 @@ do s) SDK=${OPTARG} ;; + t) + BTOOLS=${OPTARG} + ;; *) exit 4 ;; diff --git a/build-selfhosted.sh b/build-selfhosted.sh index e99fffa..095727f 100755 --- a/build-selfhosted.sh +++ b/build-selfhosted.sh @@ -5,6 +5,7 @@ usage() { echo "Where flags:" echo "-b [docker|podman] Image build tool to use - defaults to which it finds first" echo "-s SDK to use (6 or 7 ...). Default 6 for s390x and 7 for ppc64le" + echo "-t [1|0] Include tools/compilers - defaults to 0" echo "-h Display this usage information" echo echo "If no distribution is specified then images for both are built" @@ -14,6 +15,7 @@ usage() { ARCH=`uname -m` DISTROS="" BUILDER=`which podman 2>/dev/null` +BTOOLS="0" if [ -z ${BUILDER} ]; then BUILDER=`which docker 2>/dev/null` fi @@ -21,7 +23,7 @@ if [ -z ${BUILDER} ]; then echo "Need podman or docker installed" >&2 exit 1 fi -while getopts "b:hs:" opt +while getopts "b:ht:s:" opt do case "${opt}" in b) @@ -30,6 +32,9 @@ do h) usage ;; + t) + BTOOLS="${OPTARG}" + ;; s) SDK="${OPTARG}" ;; @@ -57,6 +62,6 @@ do echo "${dist} not supported" >&2 else ${BUILDER} build -f Dockerfile.${dist} --build-arg RUNNERPATCH=build-files/runner-${ARCH}.patch \ - --build-arg SDK=${SDK} --build-arg ARCH=${ARCH} --tag runner:${dist} . + --build-arg SDK=${SDK} --build-arg ARCH=${ARCH} --build-arg BTOOLS=${BTOOLS} --tag runner:${dist} . fi done diff --git a/setup-build-env.sh b/setup-build-env.sh index 3c11250..2c7ad70 100755 --- a/setup-build-env.sh +++ b/setup-build-env.sh @@ -11,6 +11,7 @@ usage() { echo "-s .NET SDK level" echo " - Defaults to value in build script for ppc64le" echo " - Ignored for s390x which uses an RPM" + echo "-t <1|0> - Include build tools/compilers in image. Defaults to 0." echo "-h Display this usage information" exit } @@ -75,8 +76,14 @@ build_image_in_container() { echo "Copy the gha-service unit file into gha-builder" lxc file push ${BUILD_PREREQS_PATH}/gha-runner.service "${BUILD_CONTAINER}/etc/systemd/system/gha-runner.service" + echo "Copy the install-python script into gha-builder" + lxc file push --mode 0755 "${BUILD_PREREQS_PATH}/install-python.sh" "${BUILD_CONTAINER}${BUILD_HOME}/install-python.sh" + + echo "Copy the install-ruby script into gha-builder" + lxc file push --mode 0755 "${BUILD_PREREQS_PATH}/install-ruby.sh" "${BUILD_CONTAINER}${BUILD_HOME}/install-ruby.sh" + echo "Running build-image.sh" - lxc exec "${BUILD_CONTAINER}" --user 1000 --group 1000 -- ${BUILD_HOME}/build-image.sh -a ${ACTION_RUNNER} ${SDK} + lxc exec "${BUILD_CONTAINER}" --user 1000 --group 1000 -- ${BUILD_HOME}/build-image.sh -a ${ACTION_RUNNER} -s ${SDK} -t ${BTOOLS} RC=$? if [ ${RC} -eq 0 ]; then @@ -113,6 +120,7 @@ prolog() { export ACTION_RUNNER="https://github.com/actions/runner" export EXPORT="distro/lxc-runner" export SDK="" + export BTOOLS="0" export OS_NAME="${OS_NAME:-ubuntu}" export OS_VERSION="${OS_VERSION:-22.04}" @@ -129,7 +137,7 @@ prolog() { } prolog -while getopts "a:o:hs:" opt +while getopts "a:o:ht:s:" opt do case "${opt}" in a) @@ -141,8 +149,11 @@ do h) usage ;; + t) + BTOOLS="${OPTARG}" + ;; s) - SDK="-s ${OPTARG}" + SDK="${OPTARG}" ;; *) usage