I am trying to create docker container for a fastapi application. This application is going to use a private pip package hosted on github.
During local development, I used the following command to install the dependency:
pip install git https://<ACCESS_TOKEN>:[email protected]/username/projectname
I tried the same approach inside dockerfile, however without success
FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
ARG ACCESS_TOKEN=default_value
RUN /usr/local/bin/python -m pip install --upgrade pip
RUN echo "pip install git https://${ACCESS_TOKEN}:[email protected]/username/projectname"
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY . /code
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
docker build --build-arg ACCESS_TOKEN=access_token_value .
The container builds without errors and during the build process I can see that the token is passed correctly.
However, after running the container with docker run <containerid>
I get the following error:
ModuleNotFoundError: No module named 'projectname'
Have anyone tried such thing before? Is it the correct approach?
CodePudding user response:
if I am not mistaken, you could run your pip command without echo
:
RUN pip install git https://${ACCESS_TOKEN}:[email protected]/username/projectname