Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README to clarify docker setup #166

Open
harrlight00 opened this issue Mar 13, 2023 · 2 comments
Open

Update README to clarify docker setup #166

harrlight00 opened this issue Mar 13, 2023 · 2 comments

Comments

@harrlight00
Copy link

I was implementing this using a docker build, and I ran into an issue that took me a while to debug, so wanted to add my knowledge here.

In addition to adding

# Copy the two files in place and fix different path/locations inside the Docker image
COPY root-config /root/
RUN sed 's|/home/runner|/root|g' -i.bak /root/.ssh/config

to the Dockerfile, you should also utilize an ssh mount with whichever command accesses the private repo. For my case, using go, I changed

RUN go mod download

to

RUN --mount=type=ssh \
   go mod download
@harrlight00
Copy link
Author

This is in addition to the necessary changes in the github actions file.

The code I needed was linked in the README (https://docs.docker.com/engine/reference/commandline/buildx_build/#ssh), but might be helpful to add a note in the README.

@LastStarDust
Copy link

On top of the --mount=type=ssh option I needed these lines in the Dockerfile:

RUN --mount=type=ssh mkdir -p -m 0700 ~/.ssh && \
    rm -rf ~/.ssh/known_hosts && \
    ssh-keyscan github.com >> ~/.ssh/known_hosts

Moreover, if the user running these commands is different from root, the --mount=type=ssh option must be complemented by --mount=type=ssh,uid=X,gid=Y where X is the correct UID and Y the GID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants