Skip to content

Instantly share code, notes, and snippets.

@os6sense
Created October 23, 2021 09:07
Show Gist options
  • Save os6sense/2673f7997cdbb1c8e97040257d746ea6 to your computer and use it in GitHub Desktop.
Save os6sense/2673f7997cdbb1c8e97040257d746ea6 to your computer and use it in GitHub Desktop.
Tilt, docker build, and ssh-agent forwarding
This took a while to figure out because the information is a bit spreadout and I was missing a piece of the puzzle.
SSH agent forwarding:
Set up ssh-agent for github and ensure your local key works
(see https://docs.github.com/en/developers/overview/using-ssh-agent-forwarding)
Tiltfile
Add ssh="default" as a parameter to the docker_build which which needs to pull from github
docker_build( 'localhost:32000/something', '../something',
dockerfile="./dockerfiles/Dockerfile.dev",
build_args={
"RUBY_VERSION": "2.7-alpine",
"NODE_ENV": "development",
"RAILS_ENV": "development",
"BUNDLER_VERSION": "2.2.25"
},
+ ssh="default",
live_update=[sync('../something/','/app')],
)
Dockerfile
Add the following at the appropriate places in your dockerfile.
RUN apk add --no-cache openssh-client
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh yarn install
You'll need to install a ssh client if there isn't one present, add github as a known ssh host, and finally any command that needs access will need the --mount=type=ssh.
You can similarly run `RUN --mount=type=ssh ssh -T git@github.com` to confirm that your ssh credentials are forwarded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment