
bitsrc/stable本镜像为Bit DevOps提供支持,包含Bit CLI及相关脚本,旨在简化CI/CD流程的自动化。适用于在各类CI/CD平台(如GitHub Actions、Azure DevOps、GitLab)中集成Bit工具,实现工作区初始化、版本检查、构建验证等自动化操作。
安装Docker Desktop。
安装VSCode Docker扩展。
安装VSCode Dev Containers扩展。
bashdocker pull bitsrc/stable:latest
启动容器后,通过Docker扩展从VSCode连接到容器。
有关最佳实践的更多信息:
yaml# @file github-action.yml name: Build on: workflow_dispatch: jobs: build: runs-on: ubuntu-latest container: image: bitsrc/stable:latest env: HOME: /home/bituser steps: - name: 初始化工作区 run: | bit -v displayName: '初始化工作区'
yaml# @file azure-pipelines.yml trigger: none pr: none jobs: - job: build displayName: 构建 pool: vmImage: 'ubuntu-latest' container: image: bitsrc/stable:latest steps: - script: | bit -v displayName: '检查Bit版本'
yaml# @file .gitlab-ci.yml image: bitsrc/stable:latest build-job: stage: build script: - | echo "bit版本: $(bit -v)"
除预安装的最新Docker版本外,镜像中还包含专用于GitLab的脚本:
gitlab.bit.initgitlab.bit.verifygitlab.bit.commit-bitmapgitlab.bi***rge-requestgitlab.bit.tag-exportgitlab.bit.branch-lanegitlab.bit.dependency-update可在GitLab流水线中如下使用:
yaml# @file .gitlab-ci.yml image: bitsrc/stable:latest variables: BIT_CONFIG_ACCESS_TOKEN: "bit_config_access_token" GIT_USER_NAME: "git_user_name" GIT_USER_*** "git_user_email" build-job: stage: build script: - | gitlab.bit.init gitlab.bit.verify rules: - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"'
容器中提供了一系列Bit实用脚本。
checkserver命令用于测试bit start和bit run <app-name>命令。
bashcheckserver <your-server-url>
可选择指定最大超时时间和检查频率,例如:
bashcd my-workspace bit start & checkserver http://localhost:3000 600 5 # 最大超时时间:600秒,检查频率:5秒
注意:执行checkserver前,需使用'&'将开发服务器置于后台运行。
barescope命令用于在CI环境中创建Bare Scope。
bashbarescope <scope-name> <workspace-directory>
该命令会创建Bare Scope并更新指定工作区目录中的远程配置,例如:
bashbarescope my-scope my-workspace cd my-workspace bit scope rename org.scope-name my-scope --refactor bit link bit compile bit tag --message "CI标签" bit export
enginestrict命令用于安装workspace.jsonc中定义的Bit引擎版本。
json"teambit.harmony/bit": { "engine": "0.2.3", "engineStrict": false // 当引擎版本与工作区不一致时警告或报错 },
注意:使用bvm list --remote可列出可用的Bit版本。
若计划向Docker Hub推送新镜像,可按以下步骤操作。
本地构建并发布Docker镜像:
shdocker buildx build --platform linux/amd64,linux/arm64 -t bitsrc/stable:latest . --push
注意:若要在本地运行构建的镜像,需使用单一平台(linux/amd64或linux/arm64),并将--push替换为--load参数。
指定镜像的自定义堆大小:
shdocker buildx build --platform linux/amd64,linux/arm64 --build-arg NODE_HEAP_SIZE=8192 -t bitsrc/stable:latest . --push
可使用本仓库中指定的GitHub Action发布镜像的新版本。
manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务