Skip to main content

devpi-server

devpi-server is a server for private package indexes and PyPI caching.

build a docker container

make a dockerfile

FROM debian:buster-slim

ENV DEBIAN_FRONTEND noninteractive
RUN apt update && \
    apt install --no-install-recommends -y \
    python3-pip python3-pip python3-setuptools python3-dev build-essential libffi-dev && \
    pip3 install devpi-server

EXPOSE 3141
VOLUME ["/var/cache/devpi"]

CMD chmod 777 /var/cache/devpi && \
    devpi-server \
        --serverdir /var/cache/devpi \
        --host 0.0.0.0 --port 3141

build an image

$ sudo docker build --build-arg http_proxy=http://192.168.xxx.xxx:3142/ -t devpi-server:buster-slim .
$ sudo docker tag devpi-server:buster-slim devpi-server:latest

run a container

$ sudo docker run --rm -d -p 3141:3141 -v /mnt/devpi:/var/cache/devpi devpi-server:latest

test the address and port

$ curl http://192.168.xxx.xxx:3141/

how to use devpi-server

specify it in a command line

$ pip3 install --trusted-host 192.168.xxx.xxx --index-url http://192.168.xxx.xxx:3141/root/pypi matplotlib

or

$ PIP_TRUSTED_HOST=192.168.xxx.xxx PIP_INDEX_URL=http://192.168.xxx.xxx:3141/root/pypi pip3 install matplotlib

for docker build, write below in a Dockerfile

ARG PIP_TRUSTED_HOST
ARG PIP_INDEX_URL

then specify devpi-server at build-arg parameter in docker run command line.

$ docker build --build-arg PIP_TRUSTED_HOST=192.168.xxx.xxx --build-arg PIP_INDEX_URL=http://192.168.xxx.xxx:3141/root/pypi -t imagename .