【问题标题】:Building and Pushing Docker image with private npm packages on GitHub Actions在 GitHub Actions 上使用私有 npm 包构建和推送 Docker 映像
【发布时间】:2022-11-10 21:07:05
【问题描述】:

我正在使用 GitHub Actions 构建和推送我的 Docker 映像。

我的 Dockerfile 中有私有 npm 包。

我需要在构建映像时安装它们。

为了安全地做到这一点,我使用--secret 标志。

最好的方法是什么?

【问题讨论】:

    标签: docker npm github-actions npm-private-modules


    【解决方案1】:

    这就是我使用 GutHub Actions 使用私有 npm 包构建 Docker 映像的方法:

    - name: Build and Push Docker image
            run: |
              echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
              docker buildx build . -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} --secret id=npmrc,src=.npmrc --push
    

    它可能不是最先进的,所以,知道我该如何改进吗?

    在此之前显然还有其他步骤,例如登录到 docker、检查分支等。

    【讨论】:

      猜你喜欢
      • 2022-11-28
      • 2020-10-28
      • 2021-01-01
      • 2021-03-26
      • 2021-08-22
      • 2021-06-10
      • 2019-05-05
      • 2020-12-18
      • 2023-02-17
      相关资源
      最近更新 更多