Ver Fonte

添加workspace dockerfile

kevin.yang há 4 dias atrás
pai
commit
78906b71a9
2 ficheiros alterados com 66 adições e 0 exclusões
  1. 20 0
      docker-compose.yml
  2. 46 0
      docker/Dockerfile.workspace

+ 20 - 0
docker-compose.yml

@@ -25,9 +25,29 @@ services:
     restart: unless-stopped
     restart: unless-stopped
     env_file:
     env_file:
       - .env
       - .env
+    volumes:
+      # workspace 与 shared 数据卷
+      - workspace_root:/root/.gateway/workspaces
+      - workspace_shared:/root/.gateway/shared
+      # 将宿主机的 docker.sock 暴露给 gateway,用于创建 workspace 容器
+      - /var/run/docker.sock:/var/run/docker.sock:ro
     networks:
     networks:
       - agent
       - agent
 
 
+  workspace:
+    build:
+      context: .
+      dockerfile: docker/Dockerfile.workspace
+    image: agent/workspace:latest
+    profiles:
+      - build-only
+    networks:
+      - agent
+
+volumes:
+  workspace_root:
+  workspace_shared:
+
 networks:
 networks:
   agent:
   agent:
     name: agent
     name: agent

+ 46 - 0
docker/Dockerfile.workspace

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