我正在尝试在dind:latest
基于 alpine 的图像中安装 azure-cli。
对于上下文,我想使用它连接到 AKS 并通过 Gitlab 将应用程序部署到 Kubernetes。
在我的gitlab-ci.yml
文件中,我从这个开始
image: docker:latest
services:
- docker:dind
然后我尝试安装 azure-cli
deploy-to-k8s--dev: # k8s namespace "dev"
stage: deploy-to-k8s
# image: microsoft/azure-cli
script:
# I need the azure cli in the dind:latest container
# so install bash,curl and finally the cli
- apk update
- apk upgrade
- apk add bash
- apk add --no-cache curl
- curl -L https://aka.ms/InstallAzureCli | bash
- az
我收到以下错误
$ curl -L https://aka.ms/InstallAzureCli | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 167 100 167 0 0 167 0 0:00:01 --:--:-- 0:00:01 644
100 1367 100 1367 0 0 1367 0 0:00:01 --:--:-- 0:00:01 1367
mktemp: Invalid argument
ERROR: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1
这是我第一次尝试使用 Alpine Linux,但我不知道它是如何构建的以及它使用什么工具......
有人有什么建议吗?
编辑
根据接受的答案,这是有效的最终代码
deploy-to-k8s--dev: # k8s namespace "dev"
stage: deploy-to-k8s
script:
# I need the azure cli in the dind:latest container
# so install bash,curl and finally the cli
- apk update
- apk upgrade
- apk add bash make py-pip
- apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python2-dev
- pip install azure-cli
- apk del --purge build
- az -h