#!/bin/bash
function handler(){
echo "Processing the Ctrl+C, trying to kill ssh agent"
ssh-agent -k
exit 0
}
trap handler SIGINT
echo "starting ssh agent..."
eval `ssh-agent` && \
echo "adding your private keys..."
ssh-add && \
echo "start building..."
DOCKER_BUILDKIT=1 docker build --ssh default=$SSH_AUTH_SOCK . -t ${1} --no-cache;
ssh-agent -k
RUN --mount=type=ssh \
mkdir -p -m 0600 ~/.ssh && ssh-keyscan [email protected] >> ~/.ssh/known_hosts && \
git clone xxxxx.git \
rm -rf ~/.ssh <your repo if you don't want to keep>