Skip to content

Commit

Permalink
Add python and ruby support in runner image
Browse files Browse the repository at this point in the history
  • Loading branch information
shahidhs-ibm committed Feb 28, 2024
1 parent fbae198 commit fe7b3ae
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 12 deletions.
17 changes: 14 additions & 3 deletions Dockerfile.almalinux
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down
30 changes: 29 additions & 1 deletion build-files/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -162,6 +187,9 @@ do
s)
SDK=${OPTARG}
;;
t)
BTOOLS=${OPTARG}
;;
*)
exit 4
;;
Expand Down
9 changes: 7 additions & 2 deletions build-selfhosted.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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"
Expand All @@ -14,14 +15,15 @@ usage() {
ARCH=`uname -m`
DISTROS=""
BUILDER=`which podman 2>/dev/null`
BTOOLS="0"
if [ -z ${BUILDER} ]; then
BUILDER=`which docker 2>/dev/null`
fi
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)
Expand All @@ -30,6 +32,9 @@ do
h)
usage
;;
t)
BTOOLS="${OPTARG}"
;;
s)
SDK="${OPTARG}"
;;
Expand Down Expand Up @@ -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
17 changes: 14 additions & 3 deletions setup-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ usage() {
echo "-s <SDK level> .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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -129,7 +137,7 @@ prolog() {
}

prolog
while getopts "a:o:hs:" opt
while getopts "a:o:ht:s:" opt
do
case "${opt}" in
a)
Expand All @@ -141,8 +149,11 @@ do
h)
usage
;;
t)
BTOOLS="${OPTARG}"
;;
s)
SDK="-s ${OPTARG}"
SDK="${OPTARG}"
;;
*)
usage
Expand Down

0 comments on commit fe7b3ae

Please sign in to comment.