尝试使用GitLabs共享运行器和
docker buildx
构建Docker镜像,以在树莓派上运行。作业失败,提示PATH中找不到git,但image: docker:stable-git
中已安装了git。是否有已知的解决方法或更好的方式来构建ARM64兼容的镜像,而无需在树莓派本身上进行构建?(由于CPU使用率过高,RPi在构建时变得无法使用)deploy:
image: docker:stable-git
stage: deploy
services:
- docker:dind
before_script:
- export DOCKER_BUILDKIT=1
- export DOCKER_CLI_EXPERIMENTAL=enabled
- docker build --platform=local -o . git://github.com/docker/buildx
- mv buildx ~/.docker/cli-plugins/docker-buildx
script:
- docker buildx build --platform linux/amd64,linux/arm64 -t $CI_REGISTRY_IMAGE .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $CI_REGISTRY_IMAGE
$ export DOCKER_BUILDKIT=1
$ export DOCKER_CLI_EXPERIMENTAL=enabled
$ docker build --platform=local -o . git://github.com/docker/buildx
#1 [internal] load git source git://github.com/docker/buildx
#1 ERROR: failed to init repo at /var/lib/docker/overlay2/xxx/diff: exec: "git": executable file not found in $PATH
------
> [internal] load git source git://github.com/docker/buildx:
------
failed to solve with frontend dockerfile.v0: failed to resolve dockerfile: failed to build LLB: failed to load cache key: failed to init repo at /var/lib/docker/overlay2/xxx/diff: exec: "git": executable file not found in $PATH
ERROR: Job failed: exit code 1
buildx
阶段:curl -sSLo ~/.docker/cli-plugins/buildx https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.linux-amd64 && chmod +x ~/.docker/cli-plugins/buildx
。 - Yajodocker-buildx
代替buildx
。另外,由于编码问题,curl
无法正常工作。可以尝试使用以下命令:wget -O ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.linux-amd64 && chmod +x ~/.docker/cli-plugins/docker-buildx
- rpi_guru