I know it's possible to supply a GitHub HTTP URL as a service's build context:
version: '3.9'
services:
my-app:
build: https://github.com/rambo/my-app.git
The above works well for public repos. But what if the Dockerfile is stored in a private repo that requires authentication (e.g. via SSH). Is something like the below example supported?
services:
my-app:
build: ssh://[email protected]:rambo/my-app.git
I've tried multiple variations of the above configuration but nothing seems to work.
Yes, you can achieve this by using github personal access token which have read access only https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token
And then your token is your username with empty password
Like, https://{token}@github.com/org_name/repo.git
This can be done via personal access token, as described by @vivek-bani, or using SSH:
your_service_name:
container_name: foo-service
build:
dockerfile: Dockerfile-compose
context: [email protected]:orgname/yourrproject.git#feature-branch
ssh: [ "default" ]
stdin_open: true
ports:
- "7000-7051:7000-7051"
Here, ssh: [ "default" ] indicates to docker compose that it should "mount the default ssh agent."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With