how to download multiple private repositories in docker

Viewed 116

I pasted a question earlier about cloning multiple private repos. I ended up getting that question answered from How to access two different private repositories created by me.

Now, my next issue is i am having trouble doing this in a docker container.

My docker file:

    # syntax = docker/dockerfile:1.0-experimental
FROM python:3.9

# create a folder and cd into it
run mkdir temp_repo
run cd temp_repo

# set folder as current working directory
workdir /temp_repo

# move hello_world.py script from our local system to current workdir in docker
add hello_world.py .

# copy the requirements file from current system to docker directory
copy requirements.txt .
run pip install -r requirements.txt
copy . /temp_repo

RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh pip install git+ssh://git@github.com/moon_research/dbreader.git
RUN --mount=type=ssh git clone git+ssh://git@github.com/moon_research/dbreader.git
RUN --mount=type=ssh pip install git+ssh://git@github.com/moon_research/trading-engine.git
copy timescale.pem /root

run apt-get update -y

cmd ["python", "-u", "hello_world.py"]

my config file:

   Host dbreader
   Hostname github.com
   User git
   IdentityFile=/Users/raj/.ssh/id_rsa

Host trading-engine
   Hostname github.com
   User git
   IdentityFile=/Users/raj/.ssh/id_rsa_docker

how am i telling docker to use the config file to access github? Thanks

1 Answers

ok, after grinding through this, there isn't really a official solution to this issue. This is what i have for anyone that might face the same option. I ended up doing the folloiwng steps:

1) ssh-keygen -t rsa -b 4096 -C "me@github.com"
2) eval "$(ssh-agent -s)”
3) ssh-add ~/.ssh/id_rsa

I then repeated the above steps but this time for id_rsa_docker. In a sense, i had two public and private keys for repo1 and repo2. I took these keys from the pub file and copied it over on the deployment keys section on github. Then i verified first whether it worked locally. That is, i verified:

git clone trading-engine:moon_research/trading-engine.git

Yep, it works. I then copied over the config file and ssh folder that contains the id_rsa and id_rsa_docker both pub and private keys Under the docker directory. Then i followed the following steps:

# syntax = docker/dockerfile:1.0-experimental
FROM python:3.9

# create a folder and cd into it
run mkdir temp_repo
run cd temp_repo

# set folder as current working directory
workdir /temp_repo

# move hello_world.py script from our local system to current workdir in docker
add hello_world.py .

# copy the requirements file from current system to docker directory
copy requirements.txt /temp_repo
run pip install -r requirements.txt

# copy github config files
copy .gitconfig* /etc/gitconfig
copy ssh/config* /etc/ssh/ssh_config
copy ssh /root/.ssh
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

RUN --mount=type=ssh pip install git+ssh://git@github.com/moon_research/dbreader.git
RUN --mount=type=ssh git clone git+ssh://git@github.com/phobos-capital/dbreader.git
RUN git clone trading-engine:moon_research/trading-engine.git

copy timescale.pem /root

run apt-get update -y


cmd ["python", "-u", "hello_world.py"]
Related