Hi all, I found this project about a week ago, and it looked like it would be really helpful in cleaning up our current messy CI workflows. The model we've decided to try is to put Dagger scripts in each repo that we are building and then combine them into a full build and publish in a centralized repo. This was partially decided because some repos only build specific applications in which multiple applications are combined into a single image.
The problem I am running into is that on macOS, the mechanism to pass in the SSH_AUTH_SOCK seems really flakey. I've tried multiple versions, and it only seems to work 15% of the time. I've dug through the GitHub issues, this Discord, and even tried asking AI, but I'm still not sure how to get it to be more reliable. I've verified that the commands Dagger is trying to run works on the local CLI, and I've made sure that ssh-add only has one key, the key I want it to use. I've also tried deleting the Docker container and pruning the cache but nothing else seems to work.
Here are a few snippets of how I have the project set up:
dagger.json:
{
"name": "project-name",
"engineVersion": "v0.20.8",
"sdk": {
"source": "python"
},
"dependencies": [
{
"name": "repo-1",
"source": "ssh://git@github.com/my-org/repo-1@feature/dagger-build",
"pin": "<..omitted..>"
},
{
"name": "repo-2",
"source": "ssh://git@github.com/my-org/repo-2@feature/dagger-build",
"pin": "<..omitted..>"
},
{
"name": "repo-3",
"source": "ssh://git@github.com/my-org/repo-3@feature/dagger-build",
"pin": "<..omitted..>"
}
],
"source": ".dagger"
}
main.py:
@object_type
class ProjectName:
@function
def build_main_from_git(
self,
sock: Socket,
repo_1_ref: str = DEFAULT_BRANCH,
repo_2_ref: str = DEFAULT_BRANCH,
platform: str = DEFAULT_PLATFORM,
) -> Container:
repo_1_src = (
dag.git("ssh://git@github.com/my-org/repo-1", ssh_auth_socket=sock)
.branch(repo_1_ref)
.tree(discard_git_dir=True)
)
repo_2_src = (
dag.git("ssh://git@github.com/my-org/repo-2", ssh_auth_socket=sock)
.branch(repo_2_ref)
.tree(discard_git_dir=True)
)
return self.build_main(repo_1_src, repo_2_src, platform)
And it would be invoked like this:
dagger -c 'build-main-from-git $SSH_AUTH_SOCK | terminal'
Any thoughts on what I might be doing wrong?
Edit: Here is a sample error I am seeing:
✘ git fetch --no-tags --update-head-ok --force --depth=1 origin <...omitted...> 40.0s ERROR
Connection closed by 140.82.114.3 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
! git error: exit status 128