Dockerfile.workspace 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. FROM python:3.11-slim
  2. ENV PYTHONUNBUFFERED=1 \
  3. PYTHONDONTWRITEBYTECODE=1 \
  4. NONINTERACTIVE=1 \
  5. CI=1 \
  6. HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api" \
  7. HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" \
  8. HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git" \
  9. HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles" \
  10. FNM_DIR=/home/agent/.fnm \
  11. FNM_NODE_DIST_MIRROR=https://mirrors.ustc.edu.cn/node/ \
  12. PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/agent/.fnm:/home/agent/.fnm/bin:$PATH"
  13. # 1、安装必要的软件包
  14. RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources \
  15. && apt-get update && apt-get install -y --no-install-recommends \
  16. sudo git curl ca-certificates zip unzip tar build-essential pkg-config jq \
  17. && rm -rf /var/lib/apt/lists/*
  18. # 2、创建 agent 用户
  19. RUN useradd -m agent && echo "agent ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
  20. USER agent
  21. WORKDIR /home/agent/workspace
  22. # 3、安装 Homebrew
  23. RUN /bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)" \
  24. && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> /home/agent/.bashrc \
  25. && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" \
  26. && brew update
  27. # 4、配置 Python 镜像
  28. RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
  29. && pip config set install.trusted-host mirrors.aliyun.com
  30. # 5、安装 fnm + node
  31. RUN brew install fnm \
  32. && echo 'eval "$(fnm env --shell bash)"' >> /home/agent/.bashrc \
  33. && eval "$(fnm env --shell bash)" \
  34. && fnm install 24 \
  35. && fnm use 24 \
  36. && npm config set registry https://registry.npmmirror.com
  37. VOLUME [ "/home/agent/workspace" ]
  38. ENTRYPOINT [ "sleep", "infinity" ]