Commit Graph

216 Commits (b42582793ae458f233c015b52b6e63cae1102502)

Author SHA1 Message Date
Ian Campbell f9a436599a client/llb: factor out `State.WithImageConfig` from `Image`.
Currently if a caller wants an `Image` (with config applied) and the
corresponding config (e.g. to use a base image and tailor the config to return
as `exptypes.ExporterImageConfigKey` in the build result) then they have to
`ResolveImageConfig` and then `llb.Image(..., llb.WithMetaResolver)`, which
ends up resolving the config twice.

Pulling this code out allows them to instead to the `config := ResolveImageConfig()`
once and to then do `llb.Image(...).WithImageConfig(config)`.

This is only really necessary if you want to run things in the image context
(and thus want the config applied) as part of tailoring the config before
returning the image and config. If you aren't running things on that `Image` as
part of the build then it doesn't matter if the config isn't applied to the
`Image` and `ResolveImageConfig` + `Image(...)` (without a metaresolver) is
fine.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-10-18 10:06:00 +01:00
Tonis Tiigi 1f51f5ea11 testutil: avoid excessive daemons in integration tests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-10-11 16:47:35 -07:00
Tibor Vass c9b01072d0 solver: specify SSH key ID in error message when required key was not forwarded
Signed-off-by: Tibor Vass <tibor@docker.com>
2018-10-05 22:50:07 +00:00
Tõnis Tiigi ad7e104d02
Merge pull request #642 from ijc/readdir
Add `ReadDir` to the gateway interface
2018-10-04 14:10:38 -07:00
Ian Campbell b4454a169f implement `gateway.Reference.StatFile` method
Signed-off-by: Ian Campbell <ijc@docker.com>
2018-10-03 12:16:45 +01:00
Ian Campbell b30ee91a53 implement `gateway.Reference.ReadDir` method
The alternative is a helper container running e.g. find, capturing the output
to a scratch to be read back (with ref.ReadFile) and parsed.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-10-03 12:16:44 +01:00
Ian Campbell 8b69292087 Bump github.com/tonistiigi/fsutil dependency to f567071bed24
7e391b0e78...f567071bed

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-10-03 11:46:35 +01:00
Tonis Tiigi cd451ec063 executor: make sure hostname is resolvable
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-10-02 23:24:37 -07:00
Tõnis Tiigi c9dc8352a4
Merge pull request #656 from AkihiroSuda/cap-ssh
define CapMountSSH
2018-10-02 23:21:17 -07:00
Akihiro Suda 758a267235 s/CapMount/CapExecMount/g
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-10-03 15:03:36 +09:00
Akihiro Suda f542300a10 client/llb: fix cap marshalling
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-10-03 15:02:08 +09:00
Akihiro Suda 900a1b96c4 define CapMountSSH
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-10-03 15:00:10 +09:00
Akihiro Suda fa92effc4b dockerfile: add support for RUN --mount=type=ssh
* Needs to be compiled with `dfrunmount dfssh`
* Implemented options:
 * `type`(required): needs to be `ssh`
 * `target`(optional): the socket path in the container
 * `id`(optional): id

Test script:

	#!/bin/bash
	set -exu -o pipefail
	REF=localhost:5000/dfssh:latest
	ssh-add -l
	sudo buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=frontend/dockerfile/cmd/dockerfile-frontend \
	  --frontend-opt "build-arg:BUILDTAGS=dfrunmount dfssh" \
	  --exporter=image --exporter-opt name=$REF --exporter-opt push=true
	mkdir -p /tmp/foo
	cd /tmp/foo
	cat << EOF > Dockerfile
	# syntax=$REF
	FROM alpine
	RUN apk add --no-cache openssh-client
	RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
	RUN --mount=type=ssh ssh git@gitlab.com
	# "Welcome to GitLab, @GITLAB_USERNAME_ASSOCIATED_WITH_SSHKEY" should be printed here
	EOF
	sudo buildctl build --ssh default=$SSH_AUTH_SOCK --progress=plain --frontend=dockerfile.v0 --local context=. --local dockerfile=.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-10-03 14:53:43 +09:00
Ian Campbell 720d8327e2 Push setting of default PATH down into the executor(s)
Setting the default `PATH` in the `llb.State` on the client side means it
depends on the `GOOS` of the buildkit client, rather than of the environment
where it will actually execute.

Instead defer this to execution time and insert the default PATH at that point
if one is not present. Doing this in solver/llbsolver/ops/exec covers all
executors and also avoids breaking the cache.

Client compatibility is handled via a new capability.

Fixes #604

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-09-28 14:16:47 +01:00
Ian Campbell 6e773ab708 Add `SetDefault` to `EnvList`
This sets an envvar only if it is not already set.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-09-28 13:42:35 +01:00
Tonis Tiigi f6e104da5f gateway: allow access to apicaps
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-21 15:33:41 -07:00
Tõnis Tiigi 39404586a5
Merge pull request #622 from tonistiigi/df-modes-switch
dockerfile: enable frontend selection in integration tests
2018-09-20 14:44:11 -07:00
Tonis Tiigi a75983ddb9 integration: pass mirrored images from test
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-18 22:07:38 -07:00
Tonis Tiigi 0940cdc6fe update golint comments
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-18 22:06:47 -07:00
Tibor Vass 36be95ea0e
Merge pull request #623 from tonistiigi/failfast
buildctl: replace withblock with dial error check
2018-09-17 11:44:57 -07:00
Akihiro Suda bf571a519e update Go to 1.11
For consistency with Moby (moby/moby#37358)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-09-15 14:25:11 +09:00
Tonis Tiigi 653fb12ecf buildctl: replace withblock with dial error check
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-13 17:29:01 -07:00
Tonis Tiigi f7120867f1 client: add regression test for closed stdin
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-11 14:26:46 -07:00
Tonis Tiigi 347420e77f sshprovider: allow keys from local files
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-10 14:12:41 -07:00
Tonis Tiigi 9337126e6e client: add ssh socket test
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-07 08:57:11 -07:00
Tonis Tiigi 6888956557 sshforward: implement ssh socket forwarding
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-07 08:57:06 -07:00
Tõnis Tiigi 9a6e2a5a91
Merge pull request #607 from kunalkushwaha/fix-typo-1
function name fixed SetMarhalDefaults -> SetMarshalDefaults
2018-09-05 22:01:39 -07:00
Kunal Kushwaha 98c1f44151 function name fixed SetMarhalDefaults -> SetMarshalDefaults
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-09-06 13:28:39 +09:00
Tonis Tiigi 079c747c4e ontrol: support calling automatic GC
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-09-04 18:13:29 -07:00
Tõnis Tiigi 05a468d460
Merge pull request #595 from tonistiigi/uid
client: reset user ID for synced dirs
2018-08-31 12:14:06 -07:00
Tõnis Tiigi 2759005f6a
Merge pull request #575 from ijc/frontend-set-export-name
exporters: allow frontend control of the exported image name
2018-08-31 10:27:09 -07:00
Ian Campbell 03a9cb89af exporter: Use "*" to signify that client allows frontend to set image name
Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-31 17:34:49 +01:00
Ian Campbell 0b20bcc8f3 The OCI image exporter does not support naming, so reject such attempts.
Adjust the test case to not name in the OCI case.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-31 14:23:34 +01:00
Ian Campbell aa51b40649 Include exported image name in ExporterResponse metadata
Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-31 11:07:32 +01:00
Tõnis Tiigi c9711fcc26
Merge pull request #574 from ijc/return-frontend-metadata
Allow some Metadata to be return from frontend to the control client
2018-08-30 10:08:51 -07:00
Ian Campbell 755bf5387e Moved some subtests into `t.Run` blocks.
Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-30 16:28:19 +01:00
Ian Campbell 3db7441e06 clarify naming in testFrontendImageNaming
Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-30 15:59:12 +01:00
Ian Campbell 8d114533c2 exports: require caller to request frontend-based naming, by passing name of `%s`.
Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-30 15:59:06 +01:00
Tonis Tiigi 64ff38f163 client: reset user ID for synced dirs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-28 14:22:22 -07:00
Akihiro Suda decb27618b containerd: set timeout explicitly (60s)
The contained default value was shortened from 60s to 10s in containerd/containerd#2554

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-08-23 18:14:57 +09:00
Ian Campbell fa39d134ee exporters: allow frontend control of the exported image name
Returning a metadata item named "image.name" will set the name to use.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-17 13:20:36 +01:00
Ian Campbell fdf13cf96e Allow some Metadata to be return from frontend to the control client
Propagate anything in the `frontend.*` namespace from the `frontend.Result`
into the `client.SolveResponse`.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-17 12:45:21 +01:00
Akihiro Suda af46188e9b
Merge pull request #533 from ijc/client-gateway
access gateway API from client
2018-08-17 05:12:23 +09:00
Ian Campbell 22f632f895 allow frontends to be run directly on the control client side
This allows builder code to be written which can be built as either a gateway
container or in a purely client side configuration, giving implementors more
flexibility.

Now when `Solve` sees a request with neither a definition nor a frontend
specified it will make the job available via new LLBBridge endpoints on the
control socket which the client can then use. These end points require the job
id to be present in the gRPC metadata and a client side object is added to
facilitate this.

The `llbBridgeForwarder` type is now exposed as a public `interface
LLBBridgeForwarder` which satisfies the underlying gRPC server interface
(`pb.LLBBridgeServer`) as well as a new `Done()` & `Result()` pair which can be
used to wait for the client to call `Return()` (using a model similar to
`context.Context`).

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-08-14 11:50:08 +01:00
Tonis Tiigi 130f5f5ab0 solver: net host with basic entitlements support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-09 14:03:35 -07:00
Tõnis Tiigi 47c4888ab1
Merge pull request #551 from tonistiigi/gc-prune
cache: add gc style pruning support
2018-08-07 11:14:46 -07:00
Tonis Tiigi 1a37ee3bf4 cache: add gc style pruning support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-06 21:45:39 -07:00
Tonis Tiigi bf29f5bd3b client: add test for extra hosts
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-03 13:56:13 -07:00
Tonis Tiigi f7359f7093 llb: add extrahost support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-03 13:56:13 -07:00
Tonis Tiigi 4c44d2c6e4 dockerfile: custom names to vertexes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-07-31 10:41:30 -07:00