Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python/Ruby/Dotnet support to GHA runner image #11

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile.almalinux
shahidhs-ibm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ RUN if [ "${BTOOLS}" -eq 1 ]; then \
chown -R almalinux:almalinux /opt/runner; \
fi

RUN if [ "${BTOOLS}" -eq 1 ]; then \
dnf install -y -q dotnet-sdk-[6-7-8]*.0; \
fi

RUN rm -rf /tmp/runner /var/cache/dnf/* /tmp/runner.patch /tmp/install-python.sh /tmp/install-ruby.sh && \
dnf clean all

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile.ubuntu
shahidhs-ibm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ RUN apt-get -qq -y install cmake make automake autoconf m4 gcc-12-base libto

COPY build-files/install-python.sh /tmp
COPY build-files/install-ruby.sh /tmp
COPY build-files/install-dotnet.sh /tmp

RUN if [ "${BTOOLS}" -eq 1 ]; then \
apt-get -qq -y install openjdk-11-jdk libssl-dev ruby perl; \
chmod +x /tmp/install-python.sh; \
/tmp/install-python.sh; \
chmod +x /tmp/install-ruby.sh; \
/tmp/install-ruby.sh; \
chmod +x /tmp/install-dotnet.sh; \
/tmp/install-dotnet.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
RUN rm -rf /tmp/runner /tmp/runner.patch /tmp/convert-rpm.sh /tmp/install-python.sh /tmp/install-ruby.sh /tmp/install-dotnet.sh

USER ubuntu

Expand Down
16 changes: 15 additions & 1 deletion build-files/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ update_fresh_container() {
}

setup_dotnet_sdk() {
if [[ "${ARCH}" = "ppc64le" && ${SDK} -eq 6 ]]; then
echo "DOTNET ${SDK} is not supported on architecture ${ARCH}" >&2
return 1
fi

MIRROR="https://mirror.lchs.network/pub/almalinux/9.3/AppStream/${ARCH}/os/Packages"
case "${SDK}" in
7)
Expand Down Expand Up @@ -140,9 +145,17 @@ install_ruby() {
return $?
}

install_dotnet() {
echo "Installing DOTNET"
chmod +x /home/ubuntu/install-dotnet.sh
sudo /home/ubuntu/install-dotnet.sh
return $?
}

cleanup() {
rm -rf /home/ubuntu/build-image.sh /home/ubuntu/runner-${ARCH}.patch \
/tmp/runner /tmp/preseed-yaml
/tmp/runner /tmp/preseed-yaml \
/home/ubuntu/install-python.sh /home/ubuntu/install-ruby.sh /home/ubuntu/install-dotnet.sh
}

run() {
Expand All @@ -161,6 +174,7 @@ run() {
if [ ${BTOOLS} -eq 1 ]; then
install_python
install_ruby
install_dotnet
RC=$?
fi
fi
Expand Down
75 changes: 75 additions & 0 deletions build-files/install-dotnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

retrieve_dotnet_pkgs() {
echo "Retrieving dotnet packages"
pushd /tmp >/dev/null
for pkg in ${PKGS}
do
RPM="${pkg}.${ARCH}.rpm"
wget -q ${MIRROR}/${RPM}
if [ ${ID} == "ubuntu" ]; then
echo -n "Converting ${RPM}... "
alien -d ${RPM} |& grep -v ^warning
if [ $? -ne 0 ]; then
exit 2
fi
rm -f ${RPM}
fi
done

echo "Installing dotnet packages"
dpkg --install /tmp/*.deb
rm -rf /tmp/*.deb
}

. /etc/os-release
DOTNET_VERSIONS="6 7 8"
ARCH=`uname -m`
MIRROR="https://mirror.lchs.network/pub/almalinux/9.3/AppStream/${ARCH}/os/Packages"

if [ "${ARCH}" == "ppc64le" ]; then
DOTNET_VERSIONS="8"
elif [ "${ARCH}" == "s390x" ]; then
DOTNET_VERSIONS="7 8"
else
DOTNET_VERSIONS="6 7 8"
fi

for dotnetver in ${DOTNET_VERSIONS}
do
case "${dotnetver}" in
8)
PKGS="dotnet-apphost-pack-8.0-8.0.1-1.el9_3 dotnet-host-8.0.1-1.el9_3"
PKGS="${PKGS} dotnet-hostfxr-8.0-8.0.1-1.el9_3 dotnet-targeting-pack-8.0-8.0.1-1.el9_3"
PKGS="${PKGS} dotnet-templates-8.0-8.0.101-1.el9_3 dotnet-runtime-8.0-8.0.1-1.el9_3"
PKGS="${PKGS} dotnet-sdk-8.0-8.0.101-1.el9_3 aspnetcore-runtime-8.0-8.0.1-1.el9_3"
PKGS="${PKGS} aspnetcore-targeting-pack-8.0-8.0.1-1.el9_3 netstandard-targeting-pack-2.1-8.0.101-1.el9_3"
retrieve_dotnet_pkgs
;;
7)
PKGS="dotnet-apphost-pack-7.0-7.0.15-1.el9_3 dotnet-host-8.0.1-1.el9_3"
PKGS="${PKGS} dotnet-hostfxr-7.0-7.0.15-1.el9_3 dotnet-targeting-pack-7.0-7.0.15-1.el9_3"
PKGS="${PKGS} dotnet-templates-7.0-7.0.115-1.el9_3 dotnet-runtime-7.0-7.0.15-1.el9_3"
PKGS="${PKGS} dotnet-sdk-7.0-7.0.115-1.el9_3 aspnetcore-runtime-7.0-7.0.15-1.el9_3"
PKGS="${PKGS} aspnetcore-targeting-pack-7.0-7.0.15-1.el9_3 netstandard-targeting-pack-2.1-8.0.101-1.el9_3"
retrieve_dotnet_pkgs
;;
6)
PKGS="dotnet-host-8.0.1-1.el9_3 dotnet-apphost-pack-6.0-6.0.26-1.el9_3"
PKGS="${PKGS} dotnet-hostfxr-6.0-6.0.26-1.el9_3 dotnet-targeting-pack-6.0-6.0.26-1.el9_3"
PKGS="${PKGS} dotnet-templates-6.0-6.0.126-1.el9_3 dotnet-runtime-6.0-6.0.26-1.el9_3"
PKGS="${PKGS} dotnet-sdk-6.0-6.0.126-1.el9_3 aspnetcore-runtime-6.0-6.0.26-1.el9_3"
PKGS="${PKGS} aspnetcore-targeting-pack-6.0-6.0.26-1.el9_3 netstandard-targeting-pack-2.1-8.0.101-1.el9_3"
retrieve_dotnet_pkgs
;;
*)
echo "Unsupported DOTNET version ${dotnetver}" >&2
exit 1
;;
esac
done

echo "List all installed .NET SDKs - `dotnet --list-sdks`"

exit 0

3 changes: 3 additions & 0 deletions setup-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ build_image_in_container() {
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 "Copy the install-dotnet script into gha-builder"
lxc file push --mode 0755 "${BUILD_PREREQS_PATH}/install-dotnet.sh" "${BUILD_CONTAINER}${BUILD_HOME}/install-dotnet.sh"

echo "Running build-image.sh"
lxc exec "${BUILD_CONTAINER}" --user 1000 --group 1000 -- ${BUILD_HOME}/build-image.sh -a ${ACTION_RUNNER} -s ${SDK} -t ${BTOOLS}
RC=$?
Expand Down
Loading