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

Add ssh to build #234

Merged
merged 8 commits into from
Mar 9, 2022
25 changes: 25 additions & 0 deletions build.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,31 @@ args:
- GIT_COMMIT
```

### ssh

`ssh` defines an SSH authentication that the image builder SHOULD use during image build (e.g., cloning private repository)
ndeloof marked this conversation as resolved.
Show resolved Hide resolved

`ssh` property syntax can be either:
* `default` - let the builder connect to the ssh-agent.
glours marked this conversation as resolved.
Show resolved Hide resolved
* `ID=path` - a key/value definition of an ID and the associated path. Can be either a [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) file, or path to ssh-agent socket

Simple`default` sample
glours marked this conversation as resolved.
Show resolved Hide resolved
```yaml
build:
context: .
ssh: default # mount the default ssh agent
```
Using a custom id `myproject` with path to a local SSH key:
```yaml
build:
context: .
ssh: myproject=~/.ssh/myproject.pem
```
Image builder can then rely on this to mount SSH key during build.
For illustration, [Buildkit extended syntax](https://github.com/compose-spec/compose-spec/pull/234/%5Bmoby/buildkit@master/frontend/dockerfile/docs/syntax.md#run---mounttypessh%5D(https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#run---mounttypessh)) can be used to mount ssh key set by ID and access a secured resource:
glours marked this conversation as resolved.
Show resolved Hide resolved

`RUN --mount=type=ssh,id=myproject git clone ...`

### cache_from

`cache_from` defines a list of sources the Image builder SHOULD use for cache resolution.
Expand Down
6 changes: 6 additions & 0 deletions schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
"context": {"type": "string"},
"dockerfile": {"type": "string"},
"args": {"$ref": "#/definitions/list_or_dict"},
"ssh": {
"oneOf": [
{"type": "string"},
ndeloof marked this conversation as resolved.
Show resolved Hide resolved
{"$ref": "#/definitions/list_or_dict"}
]
},
"labels": {"$ref": "#/definitions/list_or_dict"},
"cache_from": {"type": "array", "items": {"type": "string"}},
"cache_to": {"type": "array", "items": {"type": "string"}},
Expand Down