Created
January 30, 2020 20:29
-
-
Save nballenger/0b696299ee32b735d940b21ebb8e71d3 to your computer and use it in GitHub Desktop.
private-git-in-container-build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host github.com | |
Hostname github.com | |
User git | |
IdentityFile ~/.ssh/inside-docker-container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:experimental | |
FROM centos:centos7 AS base | |
RUN yum -y updateinfo \ | |
&& yum -y install git | |
RUN mkdir -p -m 0600 ~/.ssh \ | |
&& ssh-keyscan github.com >> ~/.ssh/known_hosts | |
RUN --mount=type=ssh git clone git@github.com:nballenger/fictional-goggles.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "create a new ssh key" | |
ssh-keygen -t rsa -b 4096 -C "you@your.domain.tld" -f ~/.ssh/inside-docker-container | |
echo "Copy ~/.ssh/inside-docker-container.pub into github as a new ssh key" | |
echo "Add the key file to your ssh agent" | |
ssh-add ~/.ssh/inside-docker-container | |
echo "Create the .ssh/config entry and the Dockerfile" | |
echo "cd to the Dockerfile's enclosing folder" | |
echo "build, with buildkit enabled by flag, so you get the --ssh option" | |
DOCKER_BUILDKIT=1 docker build -t centos-git --ssh default . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment