docker-makefile icon indicating copy to clipboard operation
docker-makefile copied to clipboard

Using ssh to access private data in builds?

Open ghost opened this issue 5 years ago • 1 comments

Using ssh to access private data in builds does not see to work with the makefile.

I get:

 => ERROR [5/9] RUN --mount=type=ssh,required GIT_SSH_COMMAND="ssh -v" git clone --progress --verbose [email protected]:worldr/private.git /app     && gi  0.1s
------
[…]
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = failed to build LLB: no SSH key "" forwarded from the client
make: *** [../make/Makefile:67: docker-build] Error 1

ghost avatar Jun 26 '20 13:06 ghost

This is a trivial fix.

In the Makefile, replace:

docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH)

with

docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_SSH) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH)

Note the new $(DOCKER_SSH) variable. In the subdirectory Makefile that need it, set

DOCKER_SSH=--ssh default

That is it.

@mvanholsteijn Do you want me to open a PR for this or is this enough?

ghost avatar Jun 26 '20 14:06 ghost