Skip to content

Commit ee3fe99

Browse files
authored
Merge pull request #276 from menloresearch/ci/add-runner-image
ci: ad docker runner image for cuda
2 parents 3d958f3 + eb3bac2 commit ee3fe99

File tree

3 files changed

+233
-0
lines changed

3 files changed

+233
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Use NVIDIA CUDA 11.7.1 development image with Ubuntu 22.04 as the base
2+
FROM nvidia/cuda:11.7.1-devel-ubuntu22.04
3+
4+
# Docker and Docker Compose arguments
5+
6+
# Use 1001 and 121 for compatibility with GitHub-hosted runners
7+
ARG RUNNER_UID=1000
8+
ARG DOCKER_GID=1001
9+
10+
ENV DEBIAN_FRONTEND=noninteractive
11+
12+
# Install necessary packages
13+
RUN apt-get update -y \
14+
&& apt-get install -y software-properties-common \
15+
&& add-apt-repository -y ppa:git-core/ppa \
16+
&& apt-get update -y \
17+
&& apt-get install -y --no-install-recommends \
18+
build-essential \
19+
curl \
20+
ca-certificates \
21+
dnsutils \
22+
ftp \
23+
git \
24+
uuid-dev \
25+
iproute2 \
26+
iputils-ping \
27+
jq \
28+
libunwind8 \
29+
locales \
30+
netcat \
31+
openssh-client \
32+
parallel \
33+
python3-pip \
34+
rsync \
35+
shellcheck \
36+
sudo \
37+
telnet \
38+
time \
39+
tzdata \
40+
unzip \
41+
upx \
42+
wget \
43+
lsb-release \
44+
openssl \
45+
libssl-dev \
46+
manpages-dev \
47+
zip \
48+
zstd \
49+
pkg-config \
50+
ccache \
51+
gcc \
52+
g++ \
53+
&& ln -sf /usr/bin/python3 /usr/bin/python \
54+
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
55+
&& rm -rf /var/lib/apt/lists/*
56+
57+
# Add Kitware's APT repository for CMake
58+
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 && \
59+
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
60+
apt-get update && \
61+
apt-get install -y cmake
62+
63+
# Download latest git-lfs version
64+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
65+
apt-get install -y --no-install-recommends git-lfs
66+
67+
RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
68+
&& groupadd docker --gid $DOCKER_GID \
69+
&& usermod -aG sudo runner \
70+
&& usermod -aG docker runner \
71+
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
72+
&& echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers
73+
74+
ENV HOME=/home/runner
75+
76+
ARG RUNNER_VERSION=2.328.0
77+
78+
# cd into the user directory, download and unzip the github actions runner
79+
RUN cd /home/runner && mkdir actions-runner && cd actions-runner \
80+
&& curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
81+
&& tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
82+
83+
RUN chown -R runner:runner /home/runner && /home/runner/actions-runner/bin/installdependencies.sh
84+
85+
ADD ./start.sh /home/runner/start.sh
86+
87+
RUN chmod +x /home/runner/start.sh
88+
89+
# Add /usr/local/cuda-11.7/compat to LD_LIBRARY_PATH
90+
ENV LD_LIBRARY_PATH=/usr/local/cuda-11.7/compat${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
91+
92+
ENTRYPOINT ["/bin/bash", "/home/runner/start.sh"]
93+
94+
USER runner
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Use NVIDIA CUDA 12.4.0 development image with Ubuntu 22.04 as the base
2+
FROM nvidia/cuda:12.4.0-devel-ubuntu22.04
3+
# Docker and Docker Compose arguments
4+
5+
# Use 1001 and 121 for compatibility with GitHub-hosted runners
6+
ARG RUNNER_UID=1000
7+
ARG DOCKER_GID=1001
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# Install necessary packages
12+
RUN apt-get update -y \
13+
&& apt-get install -y software-properties-common \
14+
&& add-apt-repository -y ppa:git-core/ppa \
15+
&& apt-get update -y \
16+
&& apt-get install -y --no-install-recommends \
17+
build-essential \
18+
curl \
19+
ca-certificates \
20+
dnsutils \
21+
ftp \
22+
git \
23+
uuid-dev \
24+
iproute2 \
25+
iputils-ping \
26+
jq \
27+
libunwind8 \
28+
locales \
29+
netcat \
30+
openssh-client \
31+
parallel \
32+
python3-pip \
33+
rsync \
34+
shellcheck \
35+
sudo \
36+
telnet \
37+
time \
38+
tzdata \
39+
unzip \
40+
upx \
41+
wget \
42+
lsb-release \
43+
openssl \
44+
libssl-dev \
45+
manpages-dev \
46+
zip \
47+
zstd \
48+
pkg-config \
49+
ccache \
50+
gcc \
51+
g++ \
52+
&& ln -sf /usr/bin/python3 /usr/bin/python \
53+
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
54+
&& rm -rf /var/lib/apt/lists/*
55+
56+
# Add Kitware's APT repository for CMake
57+
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 && \
58+
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
59+
apt-get update && \
60+
apt-get install -y cmake
61+
62+
# Download latest git-lfs version
63+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
64+
apt-get install -y --no-install-recommends git-lfs
65+
66+
RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
67+
&& groupadd docker --gid $DOCKER_GID \
68+
&& usermod -aG sudo runner \
69+
&& usermod -aG docker runner \
70+
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
71+
&& echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers
72+
73+
ENV HOME=/home/runner
74+
75+
ARG RUNNER_VERSION=2.328.0
76+
77+
# cd into the user directory, download and unzip the github actions runner
78+
RUN cd /home/runner && mkdir actions-runner && cd actions-runner \
79+
&& curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
80+
&& tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
81+
82+
RUN chown -R runner:runner /home/runner && /home/runner/actions-runner/bin/installdependencies.sh
83+
84+
ADD ./start.sh /home/runner/start.sh
85+
86+
RUN chmod +x /home/runner/start.sh
87+
88+
# Add /usr/local/cuda-11.7/compat to LD_LIBRARY_PATH
89+
ENV LD_LIBRARY_PATH=/usr/local/cuda-11.7/compat${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
90+
91+
ENTRYPOINT ["/bin/bash", "/home/runner/start.sh"]
92+
93+
USER runner

.github/runners/start.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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=$(hostname)
8+
9+
# Get the latest version of the GitHub Actions runner
10+
LATEST_VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | grep -oP '(?<=\"tag_name\": \"v)[^\"]*')
11+
OS_ARCH=$(uname -m)
12+
13+
if [[ "$OS_ARCH" == "x86_64" ]]; then
14+
ARCH="x64"
15+
elif [[ "$OS_ARCH" == "aarch64" ]]; then
16+
ARCH="arm64"
17+
else
18+
echo "Unsupported architecture: $OS_ARCH"
19+
exit 1
20+
fi
21+
22+
# Download and install the GitHub Actions runner
23+
cd /home/runner && rm -rf actions-runner && mkdir -p actions-runner && cd actions-runner
24+
curl -O -L https://github.com/actions/runner/releases/download/v${LATEST_VERSION}/actions-runner-linux-${ARCH}-${LATEST_VERSION}.tar.gz
25+
26+
tar xzf ./actions-runner-linux-${ARCH}-${LATEST_VERSION}.tar.gz
27+
28+
# Navigate to actions-runner directory
29+
cd /home/runner/actions-runner
30+
31+
./config.sh --unattended --replace --url https://github.com/${RUNNER_REPO} \
32+
--pat ${RUNNER_PAT} \
33+
--name ${RUNNER_NAME} \
34+
--runnergroup ${RUNNER_GROUP} \
35+
--labels ${RUNNER_LABELS} \
36+
--work /home/runner/actions-runner/_work
37+
38+
cleanup() {
39+
echo "Removing runner..."
40+
./config.sh remove --unattended --pat ${RUNNER_PAT}
41+
}
42+
43+
trap 'cleanup; exit 130' INT
44+
trap 'cleanup; exit 143' TERM
45+
46+
./run.sh & wait $!

0 commit comments

Comments
 (0)