Dockerfile.workspace 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 ripgrep \
  17. && rm -rf /var/lib/apt/lists/*
  18. # 2、创建 agent 用户与共享目录
  19. RUN useradd -m agent && echo "agent ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
  20. && mkdir -p /home/agent/workspace /home/agent/shared \
  21. && chown -R agent:agent /home/agent/workspace /home/agent/shared
  22. USER agent
  23. WORKDIR /home/agent/workspace
  24. # 3、安装 Homebrew
  25. RUN /bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)" \
  26. && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> /home/agent/.bashrc \
  27. && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" \
  28. && brew update
  29. # 4、配置 Python 镜像
  30. RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
  31. && pip config set install.trusted-host mirrors.aliyun.com
  32. # 5、安装 fnm + node
  33. RUN brew install fnm \
  34. && echo 'eval "$(fnm env --shell bash)"' >> /home/agent/.bashrc \
  35. && eval "$(fnm env --shell bash)" \
  36. && fnm install 24 \
  37. && fnm use 24 \
  38. && npm config set registry https://registry.npmmirror.com
  39. VOLUME [ "/home/agent/workspace", "/home/agent/shared" ]
  40. ENTRYPOINT [ "sleep", "infinity" ]