feat: add nasp-ubuntu-neo which provides cuda 12.2

This commit is contained in:
Dict Xiong 2024-09-03 12:19:26 +08:00
parent 517c5fc27d
commit 4282982c22
3 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,18 @@
FROM docker.io/nvidia/cuda:12.2.2-devel-ubuntu22.04
# Install dependencies
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& sed -i "s@http://.*archive.ubuntu.com@http://192.168.16.118/mirrors@g" /etc/apt/sources.list \
&& apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
-o Acquire::BrokenProxy="true" -o Acquire::http::No-Cache="true" -o Acquire::http::Pipeline-Depth="0" \
build-essential cmake openssh-server git-all sudo ssh sshpass pciutils \
python3 python3-dev python3-pip curl ca-certificates vim zsh tmux bash \
inetutils-ping less wget dialog net-tools dnsutils netcat traceroute \
cron htop zip openssl \
&& curl -fsSL https://code-server.dev/install.sh | sh \
&& rm -rf /var/lib/apt/list/*
# startup
COPY startup.sh /etc/startup.sh
COPY code.sh /usr/bin/code.sh
ENTRYPOINT ["/etc/startup.sh"]

23
nasp-ubuntu-neo/code.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
FMT_RED=$(printf '\033[31m')
FMT_GREEN=$(printf '\033[32m')
FMT_YELLOW=$(printf '\033[33m')
FMT_BLUE=$(printf '\033[34m')
FMT_BOLD=$(printf '\033[1m')
FMT_RESET=$(printf '\033[0m')
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
if ps -ef | grep -v grep | grep -q code-server; then
sockpath=$(basename $(grep "socket:" ~/.config/code-server/config.yaml | awk -F' ' '{print $2}') .sock)
password=$(grep "password:" ~/.config/code-server/config.yaml | awk -F' ' '{print $2}')
echo "${FMT_GREEN}code-server is running${FMT_RESET}"
echo "visit: https://proxy.nasp.fit/$(hostname)/$sockpath/"
echo "password: $password"
else
echo "${FMT_RED}code-server is not running${FMT_RESET}"
fi
else
echo "${FMT_RED}code-server is not set up${FMT_RESET}"
fi

28
nasp-ubuntu-neo/startup.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e
error() {
echo $@
return 1
}
/etc/init.d/ssh start || echo "Failed to start sshd. Maybe the port is already in use, and please check your sshd_config. This is not an error if it's the first time you run this container."
if [[ ! -e /root/.config/code-server/config.yaml ]]; then
mkdir -p /root/.config/code-server
sockname=$(openssl rand -hex 12)
test "${#sockname}" = "24" || error "invalid sock name: ${sockname}"
password=$(openssl rand -base64 15)
test -n "$password" || error "invalid password: ${password}"
cat << EOF > /root/.config/code-server/config.yaml
socket: /home2/run/$sockname.sock
socket-mode: 777
auth: password
password: $password
cert: false
EOF
fi
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
code-server
else
bash
fi