如何在 Alpine linux 上使用 azure-cli 创建 dind docker 图像?

How to create a dind docker image with azure-cli on Alpine linux?

我正在尝试在基于 alpine 的 dind:latest 映像中安装 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

这对我的一张阿尔卑斯图像很有帮助

apk update
apk add bash py-pip
apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python- dev
pip install azure-cli
apk del --purge build