scripts/docker-teambit-bit/README-zh.md
这些 Docker 容器不处理旧版的 bit (pre-harmony),对于旧版的 bit 请参考 bit-docker
Dockerfile-bit 的 Dockerfile。它创建一个空的 scope,并在其上初始化 bit 服务器 (bit start)。Docker 镜像托管在 Dockerhub,链接是 Dockerfile-bit 和 Dockerfile-bit-server。
cd scripts/docker-teambit-bitdocker build -f ./Dockerfile-bit -t bitcli/bit:latest .docker build -f ./Dockerfile-bit-server -t bitcli/bit-server:latest .docker run -it bitcli/bit:latest /bin/bashbit -v 查看 bit 版本以确保工作正常。docker run -it -p {host-port}:3000 bitcli/bit-server:latest - 将 {host-port} 替换为主机要使用的端口,例如 5000。http://localhost:{host-port} 并确保可以看到 bit 的界面。bit remote add http://localhost:{host-port},应该会看到 remote-scope 已添加的消息。workspace.jsonc 中将 remote-scope 设为 defaultScope。bit export。Bit 服务器会读取一个用于 FROM 语句的参数 BIT_VERSION。你可以通过 docker build -f ./Dockerfile-bit-server --build-arg BIT_VERSION={version} -t bitcli/bit-server:{version} . 来使用它。这会让你的服务器从 Dockerhub 获取指定版本的 cli 容器。
scope 的名称由包含 scope 的文件夹名称定义(默认为 remote-scope)。这个名称后来会被设置于 workspace.jsonc 文件中。如果要更改,可以传递名为 SCOPE_PATH 的构建参数,如 --build-arg SCOPE_PATH=/root/custom-remote-scope。
为了使 scope 数据持久化,你需要将 scope 文件夹放置在容器外的主机上。你可以通过绑定挂载来实现:docker run -it -v {scope-path-on-host}:/root/remote-scope -p {host-port}:3000 bitcli/bit-server:latest。
通常使用 volume 比绑定挂载好,甚至可以由诸如 Kubernetes 之类的编排器来处理挂载,但这超出了本指南讨论的范围。
当同时更改 scope 名称/位置和 volume 时,你需要确保构建参数 SCOPE_PATH 中提供的位置与 volume 中的目标匹配:docker run -it -v {scope-path-on-host}:/root/custom-remote-scope -build-arg SCOPE_PATH=/root/custom-remote-scope -p {host-port}:3000 bitcli/bit-server:latest。请注意 /root/custom-remote-scope 既用在了 -v 参数的 : 之后,又用于了 SCOPE_PATH 的值。
由于目前 bit start 命令无法以分离方式运行,因此需要一种方法同时将其作为主命令运行且监控日志。为此,我们将使用绑定挂载将容器上的日志目录连接到主机上的目录。为了观察 bit 日志,你需要挂载主机上的日志目录,如:docker run -it -v {logs-dir-on-host}:/root/Library/Caches/Bit/logs -p {host-port}:3000 bitcli/bit-server:latest。举一个实际的例子 (在主机上使用 /root/bit-server-docker-logs 作为日志目录,主机端口为 5000):docker run -it -v /root/bit-server-docker-logs:/root/Library/Caches/Bit/logs -p 5000:3000 bitcli/bit-server:latest。
在大多数情况下,最好对此使用 tmpfs 挂载,但这也超出了本指南讨论的范围。
NODE_OPTIONS=--max_old_space_size=4096)。例如在 Mac 上:docker for mac resources。