add node runner

This commit is contained in:
Timi
2026-01-29 01:34:54 +08:00
parent 31c084ab0d
commit bffb0ac11f
2 changed files with 201 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# syntax=docker/dockerfile:1
# Gitea Action Runner Node.js Image
# 基于 gitea_runner_base 添加多版本 Node.js 和包管理器
FROM timi/gitea_runner_base:latest
LABEL maintainer="www.imyeyu.com"
LABEL description="Gitea Action Runner with Node.js 18/20/22 and multiple package managers"
# Node.js 安装目录
ENV NODE_BASE=/usr/local/node
# 安装 Node.js 多版本环境和包管理器
RUN npm install -g n \
&& mkdir -p ${NODE_BASE} \
&& n install 18 \
&& n install 20 \
&& n install 22 \
&& n use 20 \
&& npm install -g yarn pnpm \
&& cat <<'EOF' > /usr/local/bin/use-node \
#!/bin/bash
case "$1" in
18|20|22)
n use "$1" > /dev/null 2>&1
export PATH="/usr/local/n/versions/node/$1/bin:${PATH}"
echo "Switched to Node.js $1: $(node -v)"
;;
*)
echo "Usage: source use-node [18|20|22]"
return 1
;;
esac
EOF
&& chmod +x /usr/local/bin/use-node