Reputation: 1610
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.
Upvotes: 2
Views: 11142
Reputation: 2015
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."
Upvotes: 4
Reputation: 3920
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
Upvotes: 6