mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-04-24 23:12:13 +00:00
Clarify usage of docker build and deploy keys
The current docs mention only `docker/build-push-action` in conjunction with deploy keys. This might mislead users to believe, that this only applies to said Action. But the concept applies to all workflows that somehow use `docker build` with deploy keys. This PR clarifies the relevant section.
This commit is contained in:
parent
4512be8010
commit
9556550dfa
1 changed files with 21 additions and 9 deletions
30
README.md
30
README.md
|
@ -123,25 +123,35 @@ If you are using the `docker/build-push-action`, and would like to pass the SSH
|
|||
default=${{ env.SSH_AUTH_SOCK }}
|
||||
```
|
||||
|
||||
### Using the `docker/build-push-action` Action together with multiple Deploy Keys
|
||||
### Using docker based workflows together with multiple Deploy Keys
|
||||
|
||||
If you use the `docker/build-push-action` and want to use multiple GitHub deploy keys, you need to copy the git and ssh configuration to the container during the build. Otherwise, the Docker build process would still not know how to handle multiple deploy keys. Even if the ssh agent was set up correctly on the runner.
|
||||
If you use one of:
|
||||
* the `docker/build-push-action`
|
||||
* manual `docker build`
|
||||
* manual `docker compose build`
|
||||
|
||||
This requires an additional step in the actions workflow and two additional lines in the Dockerfile.
|
||||
and want to use multiple GitHub deploy keys, you need to copy the git and ssh configuration to the container during the build. Otherwise, the Docker build process would still not know how to handle multiple deploy keys. Even if the ssh agent was set up correctly on the runner.
|
||||
|
||||
This requires an additional step in the actions workflow **after** the ssh-agent step and **before** the docker build step.
|
||||
You also need two additional lines in the Dockerfile to actually copy the configs.
|
||||
|
||||
This does the following:
|
||||
* make the git and ssh configs accessible to Docker
|
||||
* copy the configs into the build stage
|
||||
|
||||
Workflow:
|
||||
```yml
|
||||
- name: ssh-agent setup
|
||||
...
|
||||
|
||||
- name: Prepare git and ssh config for build context
|
||||
run: |
|
||||
mkdir root-config
|
||||
cp -r ~/.gitconfig ~/.ssh root-config/
|
||||
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
ssh: |
|
||||
default=${{ env.SSH_AUTH_SOCK }}
|
||||
- name: Docker build
|
||||
# build-push-action | docker [compose] build | etc.
|
||||
...
|
||||
```
|
||||
|
||||
Dockerfile:
|
||||
|
@ -152,6 +162,8 @@ RUN sed 's|/home/runner|/root|g' -i.bak /root/.ssh/config
|
|||
|
||||
Have in mind that the Dockerfile now contains customized git and ssh configurations. If you don't want that in your final image, use multi-stage builds.
|
||||
|
||||
If you still get the error message: `fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.` you most likely forgot one of the steps above.
|
||||
|
||||
|
||||
### Cargo's (Rust) Private Dependencies on Windows
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue