This repo contains a docker image for the devpi PyPI server along with the configuration files needed for the deployment on Google Container Engine (Kubernetes). The built image is available on Docker Hub: fyndiq/docker-devpi
The configuration for Kubernetes is stored in the devpi-app.yaml
file. By default
a private pypi index will be created that requires HTTP Basic Authentication (via nginx)
to access it.
The configuration is specified with the following environment variables:
DEVPI_SERVERDIR
: Directory for server files (default:/data/server
)DEVPI_CLIENTDIR
: Directory for client files (default:/data/client
)DEVPI_ROOT_PASSWORD
: Password for root user (user who can create or modify indexes)DEVPI_USER
: UsernameDEVPI_PASSWORD
: PasswordDEVPI_INDEX
: Index name (default:dev
. The index where custom packages can be uploaded)
The user credentials are stored in a Kubernetes secret. Before creating one, an htpasswd file (for HTTP Basic Auth) needs to be generated:
htpasswd -bn testuser testpassword > htpasswd
Note that due to a issue with devpi-client, the http auth and devpi auth credentials need to be the same.
The Kubernetes secret can be created with the following command:
kubectl create secret generic devpi \
--from-literal=root-password=pleasechangeme \
--from-literal=user=testuser \
--from-literal=password=testpassword \
--from-file=htpasswd
A configmap for nginx needs to be created (If you want to remove the authentication part and run a publicly available index you can modify the config at this step):
kubectl create configmap nginx-conf --from-file=nginx.conf
To have persistent storage a Google Compute Disk needs to be created. It must
have the name devpi-disk
.
gcloud compute disks create --size=10GB devpi-disk
To deploy the service:
kubectl create -f devpi-app.yaml
To check the logs:
kubectl get pods # to get the pod name e.g. "devpi-2096512311-3s8j2"
kubectl logs -f <pod_name>
To get the external ip address:
kubectl get services devpi
pip install -i http://testuser:testpassword@<external_ip>/testuser/dev/+simple/ --trusted-host <external_ip> Flask
To permanently use the new index create a ~/.pip/pip.conf
file with the following content:
[global]
index-url = http://testuser:testpassword@<external_ip>/testuser/dev/+simple/
trusted-host = <external_ip>
The following example shows how to build a wheel for Pandas and upload it to the index. Make sure you have the devpi-client installed.
pip install cython # Cython is required to build Pandas
git clone https://github.com/pydata/pandas.git
cd pandas
git checkout v0.16.2
devpi use http://testuser:testpassword@<external_ip>/testuser/dev
devpi login testuser --password=testpassword
devpi upload --formats bdist_wheel
Finally, test the installation by running:
pip install --no-cache --verbose Pandas==0.16.2