【发布时间】:2022-11-10 21:07:05
【问题描述】:
我正在使用 GitHub Actions 构建和推送我的 Docker 映像。
我的 Dockerfile 中有私有 npm 包。
我需要在构建映像时安装它们。
为了安全地做到这一点,我使用--secret 标志。
最好的方法是什么?
【问题讨论】:
标签: docker npm github-actions npm-private-modules
我正在使用 GitHub Actions 构建和推送我的 Docker 映像。
我的 Dockerfile 中有私有 npm 包。
我需要在构建映像时安装它们。
为了安全地做到这一点,我使用--secret 标志。
最好的方法是什么?
【问题讨论】:
标签: docker npm github-actions npm-private-modules
这就是我使用 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、检查分支等。
【讨论】: