I am building an app that has a dependency available on a private Pypi server.
My Dockerfile looks like this:
FROM python:3.6
WORKDIR /src/mylib
COPY . ./
RUN pip install .
I want pip to use the extra server to install the dependencies. So I'm trying to pass the PIP_EXTRA_INDEX_URL
environment variable during the build phase like so:
"docker build --pull -t $IMAGE_TAG --build-arg PIP_EXTRA_INDEX_URL=$PIP_EXTRA_INDEX_URL ."
For some reason it is not working as intended, and RUN echo $PIP_EXTRA_INDEX_URL
returns nothing.
What is wrong?
You should add ARG
to your Dockerfile
. Your Dockerfile should look like this:
FROM python:3.6
ARG PIP_EXTRA_INDEX_URL
# YOU CAN ALSO SET A DEFAULT VALUE:
# ARG PIP_EXTRA_INDEX_URL=DEFAULT_VALUE
RUN echo "PIP_EXTRA_INDEX_URL = $PIP_EXTRA_INDEX_URL"
# you could also use braces - ${PIP_EXTRA_INDEX_URL}
WORKDIR /src/mylib
COPY . ./
RUN pip install .
If you want to know more, take a look this article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With