Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 1167025

Browse files
authored
Feature nitro distribution (#315)
Co-authored-by: Hien To <tominhhien97@gmail.com>
1 parent 2411d3b commit 1167025

File tree

7 files changed

+378
-80
lines changed

7 files changed

+378
-80
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Use NVIDIA CUDA 12.0.0 development image with Ubuntu 18.04 as the base
2+
FROM nvidia/cuda:11.4.3-devel-ubuntu18.04
3+
4+
ARG RUNNER_VERSION=2.298.2
5+
# Docker and Docker Compose arguments
6+
7+
# Use 1001 and 121 for compatibility with GitHub-hosted runners
8+
ARG RUNNER_UID=1000
9+
ARG DOCKER_GID=1001
10+
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# Install necessary packages
14+
RUN apt-get update -y \
15+
&& apt-get install -y software-properties-common \
16+
&& add-apt-repository -y ppa:git-core/ppa \
17+
&& apt-get update -y \
18+
&& apt-get install -y --no-install-recommends \
19+
build-essential \
20+
curl \
21+
ca-certificates \
22+
dnsutils \
23+
ftp \
24+
git \
25+
uuid-dev \
26+
iproute2 \
27+
iputils-ping \
28+
jq \
29+
libunwind8 \
30+
locales \
31+
netcat \
32+
openssh-client \
33+
parallel \
34+
python3-pip \
35+
rsync \
36+
shellcheck \
37+
sudo \
38+
telnet \
39+
time \
40+
tzdata \
41+
unzip \
42+
upx \
43+
wget \
44+
lsb-release \
45+
openssl \
46+
manpages-dev \
47+
zip \
48+
zstd \
49+
&& ln -sf /usr/bin/python3 /usr/bin/python \
50+
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
51+
&& rm -rf /var/lib/apt/lists/*
52+
53+
# Add Kitware's APT repository for CMake
54+
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
55+
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
56+
apt-get update && \
57+
apt-get install -y cmake
58+
59+
# Add PPA for newer versions of GCC
60+
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
61+
apt-get update && \
62+
apt-get install -y gcc-11 g++-11 cpp-11 && \
63+
# Clean up
64+
apt-get clean
65+
66+
# Update alternatives for GCC and related tools
67+
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 \
68+
--slave /usr/bin/g++ g++ /usr/bin/g++-11 \
69+
--slave /usr/bin/gcov gcov /usr/bin/gcov-11 \
70+
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 \
71+
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 && \
72+
update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-11 110
73+
74+
# Download latest git-lfs version
75+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
76+
apt-get install -y --no-install-recommends git-lfs
77+
78+
RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
79+
&& groupadd docker --gid $DOCKER_GID \
80+
&& usermod -aG sudo runner \
81+
&& usermod -aG docker runner \
82+
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
83+
&& echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers
84+
85+
ENV HOME=/home/runner
86+
87+
# cd into the user directory, download and unzip the github actions runner
88+
RUN cd /home/runner && mkdir actions-runner && cd actions-runner \
89+
&& curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
90+
&& tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
91+
92+
RUN chown -R runner:runner /home/runner && /home/runner/actions-runner/bin/installdependencies.sh
93+
94+
ADD start.sh start.sh
95+
96+
RUN chmod +x start.sh
97+
98+
# Add /usr/local/cuda-11.4/compat to LD_LIBRARY_PATH
99+
ENV LD_LIBRARY_PATH=/usr/local/cuda-11.4/compat${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
100+
101+
USER runner
102+
103+
ENTRYPOINT ["./start.sh"]
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Use NVIDIA CUDA 12.0.0 development image with Ubuntu 18.04 as the base
2+
FROM nvidia/cuda:12.0.0-devel-ubuntu18.04
3+
4+
ARG RUNNER_VERSION=2.298.2
5+
# Docker and Docker Compose arguments
6+
7+
# Use 1001 and 121 for compatibility with GitHub-hosted runners
8+
ARG RUNNER_UID=1000
9+
ARG DOCKER_GID=1001
10+
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# Install necessary packages
14+
RUN apt-get update -y \
15+
&& apt-get install -y software-properties-common \
16+
&& add-apt-repository -y ppa:git-core/ppa \
17+
&& apt-get update -y \
18+
&& apt-get install -y --no-install-recommends \
19+
build-essential \
20+
curl \
21+
ca-certificates \
22+
dnsutils \
23+
ftp \
24+
git \
25+
uuid-dev \
26+
iproute2 \
27+
iputils-ping \
28+
jq \
29+
libunwind8 \
30+
locales \
31+
netcat \
32+
openssh-client \
33+
parallel \
34+
python3-pip \
35+
rsync \
36+
shellcheck \
37+
sudo \
38+
telnet \
39+
time \
40+
tzdata \
41+
unzip \
42+
upx \
43+
wget \
44+
lsb-release \
45+
openssl \
46+
manpages-dev \
47+
zip \
48+
zstd \
49+
&& ln -sf /usr/bin/python3 /usr/bin/python \
50+
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
51+
&& rm -rf /var/lib/apt/lists/*
52+
53+
# Add Kitware's APT repository for CMake
54+
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
55+
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
56+
apt-get update && \
57+
apt-get install -y cmake
58+
59+
# Add PPA for newer versions of GCC
60+
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
61+
apt-get update && \
62+
apt-get install -y gcc-11 g++-11 cpp-11 && \
63+
# Clean up
64+
apt-get clean
65+
66+
# Update alternatives for GCC and related tools
67+
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 \
68+
--slave /usr/bin/g++ g++ /usr/bin/g++-11 \
69+
--slave /usr/bin/gcov gcov /usr/bin/gcov-11 \
70+
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 \
71+
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 && \
72+
update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-11 110
73+
74+
# Download latest git-lfs version
75+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
76+
apt-get install -y --no-install-recommends git-lfs
77+
78+
RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
79+
&& groupadd docker --gid $DOCKER_GID \
80+
&& usermod -aG sudo runner \
81+
&& usermod -aG docker runner \
82+
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
83+
&& echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers
84+
85+
ENV HOME=/home/runner
86+
87+
# cd into the user directory, download and unzip the github actions runner
88+
RUN cd /home/runner && mkdir actions-runner && cd actions-runner \
89+
&& curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
90+
&& tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
91+
92+
RUN chown -R runner:runner /home/runner && /home/runner/actions-runner/bin/installdependencies.sh
93+
94+
ADD start.sh start.sh
95+
96+
RUN chmod +x start.sh
97+
98+
# Add /usr/local/cuda-12.0/compat to LD_LIBRARY_PATH
99+
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.0/compat${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
100+
101+
USER runner
102+
103+
ENTRYPOINT ["./start.sh"]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM mcr.microsoft.com/windows/server:ltsc2022
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]
4+
5+
ARG RUNNER_VERSION=2.298.2
6+
7+
RUN Invoke-WebRequest \
8+
-Uri 'https://aka.ms/install-powershell.ps1' \
9+
-OutFile install-powershell.ps1; \
10+
powershell -ExecutionPolicy Unrestricted -File ./install-powershell.ps1 -AddToPath
11+
12+
RUN Invoke-WebRequest \
13+
-Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip \
14+
-OutFile runner.zip; \
15+
Expand-Archive -Path C:/runner.zip -DestinationPath C:/actions-runner; \
16+
Remove-Item -Path C:\runner.zip; \
17+
setx /M PATH $(${Env:PATH} + \";${Env:ProgramFiles}\Git\bin\")
18+
19+
# Install Chocolatey
20+
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
21+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; \
22+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
23+
24+
# Upgrade Git
25+
RUN choco install git -y; \
26+
git --version
27+
28+
# Install 7zip
29+
RUN choco install 7zip -y; \
30+
7z --help
31+
32+
# Install cmake and add to path
33+
RUN choco install cmake.install -y --installargs '"ADD_CMAKE_TO_PATH=System"'
34+
35+
RUN cmake --version
36+
37+
# Install MSBuild and add to path
38+
RUN choco install visualstudio2019buildtools -y --package-parameters '"--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.Component.VC.14.29.CLI.Support --add Microsoft.VisualStudio.Component.VC.14.29.CMake.Project --add Microsoft.VisualStudio.Component.VC.14.29.MFC --add Microsoft.VisualStudio.Component.VC.14.29.MSBuild --add Microsoft.VisualStudio.Component.VC.14.29.VCRedist.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VSTools.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VC.ASAN --add Microsoft.VisualStudio.Component.VC.14.29.VC.CLI.Support --add Microsoft.VisualStudio.Component.VC.14.29.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.14.29.VC.FxCop --add Microsoft.VisualStudio.Component.VC.14.29.VC.MFC --add Microsoft.VisualStudio.Component.VC.14.29.VC.MSBuild --add Microsoft.VisualStudio.Component.VC.14.29.VC.Redist.14.Latest --add Microsoft.VisualStudio.Component.VC.14.29.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VC.VCUnitTest --add Microsoft.VisualStudio.Component.VC.14.29.VC.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VC.x86.x64.Latest --add Microsoft.VisualStudio.Component.VC.14.29.VisualStudioCppSDK --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win10 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.LegacyBuildTools --add Microsoft.VisualStudio.Component.VC.ATL --add Microsoft.VisualStudio.Component.VC.CLI.Support --add Microsoft.VisualStudio.Component.VC.CoreIde --add Microsoft.VisualStudio.Component.VC.DiagnosticTools --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.VC.Llvm.Cmake --add Microsoft.VisualStudio.Component.VC.Llvm.Llvm --add Microsoft.VisualStudio.Component.VC.Llvm.Toolset --add Microsoft.VisualStudio.Component.VC.MFC --add Microsoft.VisualStudio.Component.VC.MSBuild --add Microsoft.VisualStudio"'
39+
40+
RUN choco install gzip -y;
41+
42+
# Install cuda toolkit 11.4.4
43+
RUN choco install cuda --version=11.4.2.47141 -y
44+
45+
# Copy integrated tools to MSBuild
46+
RUN Copy-Item -Path 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\extras\visual_studio_integration\MSBuildExtensions\*' -Destination 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\BuildCustomizations'
47+
48+
49+
ADD runner.ps1 C:/runner.ps1
50+
CMD ["pwsh", "-ExecutionPolicy", "Unrestricted", "-File", ".\\runner.ps1"]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM mcr.microsoft.com/windows/server:ltsc2022
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]
4+
5+
ARG RUNNER_VERSION=2.298.2
6+
7+
RUN Invoke-WebRequest \
8+
-Uri 'https://aka.ms/install-powershell.ps1' \
9+
-OutFile install-powershell.ps1; \
10+
powershell -ExecutionPolicy Unrestricted -File ./install-powershell.ps1 -AddToPath
11+
12+
RUN Invoke-WebRequest \
13+
-Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip \
14+
-OutFile runner.zip; \
15+
Expand-Archive -Path C:/runner.zip -DestinationPath C:/actions-runner; \
16+
Remove-Item -Path C:\runner.zip; \
17+
setx /M PATH $(${Env:PATH} + \";${Env:ProgramFiles}\Git\bin\")
18+
19+
# Install Chocolatey
20+
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
21+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; \
22+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
23+
24+
# Upgrade Git
25+
RUN choco install git -y; \
26+
git --version
27+
28+
# Install 7zip
29+
RUN choco install 7zip -y; \
30+
7z --help
31+
32+
# Install cmake and add to path
33+
RUN choco install cmake.install -y --installargs '"ADD_CMAKE_TO_PATH=System"'
34+
35+
RUN cmake --version
36+
37+
# Install MSBuild and add to path
38+
RUN choco install visualstudio2022buildtools -y --package-parameters '"--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.Component.VC.14.29.CLI.Support --add Microsoft.VisualStudio.Component.VC.14.29.CMake.Project --add Microsoft.VisualStudio.Component.VC.14.29.MFC --add Microsoft.VisualStudio.Component.VC.14.29.MSBuild --add Microsoft.VisualStudio.Component.VC.14.29.VCRedist.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VSTools.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VC.ASAN --add Microsoft.VisualStudio.Component.VC.14.29.VC.CLI.Support --add Microsoft.VisualStudio.Component.VC.14.29.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.14.29.VC.FxCop --add Microsoft.VisualStudio.Component.VC.14.29.VC.MFC --add Microsoft.VisualStudio.Component.VC.14.29.VC.MSBuild --add Microsoft.VisualStudio.Component.VC.14.29.VC.Redist.14.Latest --add Microsoft.VisualStudio.Component.VC.14.29.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VC.VCUnitTest --add Microsoft.VisualStudio.Component.VC.14.29.VC.x86.x64 --add Microsoft.VisualStudio.Component.VC.14.29.VC.x86.x64.Latest --add Microsoft.VisualStudio.Component.VC.14.29.VisualStudioCppSDK --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win10 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.LegacyBuildTools --add Microsoft.VisualStudio.Component.VC.ATL --add Microsoft.VisualStudio.Component.VC.CLI.Support --add Microsoft.VisualStudio.Component.VC.CoreIde --add Microsoft.VisualStudio.Component.VC.DiagnosticTools --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.VC.Llvm.Cmake --add Microsoft.VisualStudio.Component.VC.Llvm.Llvm --add Microsoft.VisualStudio.Component.VC.Llvm.Toolset --add Microsoft.VisualStudio.Component.VC.MFC --add Microsoft.VisualStudio.Component.VC.MSBuild --add Microsoft.VisualStudio"'
39+
40+
RUN choco install gzip -y;
41+
42+
# Install cuda toolkit 12.0.4
43+
RUN choco install cuda --version=12.0.1.52833 -y
44+
45+
# Copy integrated tools to MSBuild
46+
RUN Copy-Item -Path 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\extras\visual_studio_integration\MSBuildExtensions\*' -Destination 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\BuildCustomizations'
47+
RUN Copy-Item -Path 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\extras\visual_studio_integration\MSBuildExtensions\*' -Destination 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v160\BuildCustomizations'
48+
49+
50+
ADD runner.ps1 C:/runner.ps1
51+
CMD ["pwsh", "-ExecutionPolicy", "Unrestricted", "-File", ".\\runner.ps1"]

.github/runners/runner.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.\actions-runner\config.cmd --unattended --replace --url https://github.com/${env:RUNNER_REPO} --pat $env:RUNNER_PAT --runnergroup $env:RUNNER_GROUP --labels $env:RUNNER_LABELS --name $env:RUNNER_NAME --work $env:RUNNER_WORKDIR;
2+
.\actions-runner\run.cmd;

.github/runners/start.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
RUNNER_REPO=$RUNNER_REPO
4+
RUNNER_PAT=$RUNNER_PAT
5+
RUNNER_GROUP=$RUNNER_GROUP
6+
RUNNER_LABELS=$RUNNER_LABELS
7+
RUNNER_NAME=$RUNNER_NAME
8+
9+
cd /home/runner/actions-runner
10+
11+
./config.sh --unattended --replace --url https://github.com/${RUNNER_REPO} --pat ${RUNNER_PAT} --name ${RUNNER_NAME} --runnergroup ${RUNNER_GROUP} --labels ${RUNNER_LABELS} --work /home/runner/actions-runner/_work
12+
13+
cleanup() {
14+
echo "Removing runner..."
15+
./config.sh remove --unattended --pat ${RUNNER_PAT}
16+
}
17+
18+
trap 'cleanup; exit 130' INT
19+
trap 'cleanup; exit 143' TERM
20+
21+
./run.sh & wait $!

0 commit comments

Comments
 (0)