Open ruanshudong opened 2 years ago
Looking at https://github.com/moby/buildkit/pull/1533 you could use GIT_AUTH_TOKEN.<host>
but as the token is scoped to the host (github.com
in your case) you cannot do this.
Another way is to set the username in the URL like https://user1@github.com
and https://user2@github.com
but in your case it's the same one (TarsCloudMarket
).
To fix this we need some changes on BuildKit repo as atm there is only a best-effort to try reusing the same token for all github.com
remotes (https://github.com/moby/buildkit/pull/1987). I think we would just need to include the path to the domain in http.<url>.*
to fix it or maybe we could also set credential.usehttppath
or credential.<host>.useHttpPath
so it would be scoped to the path. cc @tonistiigi
docker/build-push-action@v3 uses Git context by default, but you can override it by setting context explicitly. This allows you to mutate the context using any actions, including actions/checkout@v3 with submodules (we use dedicated GitHub account for automation, then add that account's SSH key to repository secrets as DEPLOYER_SSHKEY):
jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout with submodules
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOYER_SSHKEY }}
submodules: true
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: 'user/app:tag'
Would love some additional explanation regarding the context
flag.
I've encountered the same issue, and after @crazy-max insights indeed adding context: .
solved my issue.
I've read the documentation (https://github.com/docker/build-push-action?tab=readme-ov-file#git-context & https://docs.docker.com/reference/cli/docker/image/build/#git-repositories), and from what I understood it simply tells docker where is the Dockerfile located (not path to file, but context such as "this current repo").
So by default it's taking the current repo, cloning it and then proceeding, and if mentioning the context as I did it simply skips the checkout part? (as long as it's the current repo).