From fc9a81700273236bf090cd8b6d78707ac7ea930c Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 26 May 2020 16:38:13 +0300 Subject: [PATCH] Use ssh-agent for docker builds --- build-machine/bin/docker-entrypoint.sh | 3 +++ build-machine/build.sh | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build-machine/bin/docker-entrypoint.sh b/build-machine/bin/docker-entrypoint.sh index f749ed045..6442bdaa8 100755 --- a/build-machine/bin/docker-entrypoint.sh +++ b/build-machine/bin/docker-entrypoint.sh @@ -4,6 +4,9 @@ # The last arguments is to change owner of the final tarball in the # mounted volume. +mkdir -p ~/.ssh +ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + git clone --depth 1 -b ${1} ${2} server cd server make tar diff --git a/build-machine/build.sh b/build-machine/build.sh index aaccf18c2..5d5a4629e 100755 --- a/build-machine/build.sh +++ b/build-machine/build.sh @@ -68,6 +68,7 @@ test -d tarballs || mkdir tarballs docker run --rm \ --mount source="$(pwd)/tarballs",target=/build-root/tarballs,type=bind \ --mount source="$(pwd)/bin",target=/build-root/bin,type=bind \ - --mount source="${SSH_DIR}",target=/root/.ssh,readonly,type=bind \ + --mount type=bind,src=/run/host-services/ssh-auth.sock,target=/run/host-services/ssh-auth.sock \ + -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \ -it \ ${DOCKER_IMAGE} ${GIT_BRANCH} ${GIT_REMOTE} $(id -u) $(id -g) -- GitLab