Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pip install private repo on python Docker

How can I install a private repo inside a python image docker? I tried many alternatives but all were unsuccesful. Seems I cant get to set ssh credentials inside a python based image.

My Docker image:

FROM python:3.8

ENV PATH="/scripts:${PATH}"

# Django files
COPY ./requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

the requirements file has:

git+ssh://[email protected]/my_repo_name.git@dev

And build is triggered from aocker compose file:

....
django_service:
    build: 
        context: ..
        dockerfile: Dockerfile
    volumes:
        - static_data:/vol/web
    environment: 
        - SECRET_KEY=${SECRET_KEY}

    depends_on: 
 ....
like image 233
esantix Avatar asked Jun 06 '26 07:06

esantix


1 Answers

Perhaps you could use https instead of ssh:
git clone https://${GH_TOKEN}@github.com/username/my_repo_name.git@dev

To set the token inside the Dockerfile use: ARG GH_TOKEN
To keep the token outside the Dockerfile you can build your docker image with passing the arg like this --build-arg GH_TOKEN=MY_TOKEN

like image 72
Pamela Sarkisyan Avatar answered Jun 07 '26 22:06

Pamela Sarkisyan