You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.9 KiB

11 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. docker-devpi
  2. ============
  3. This repository contains a Dockerfile for [devpi pypi server](http://doc.devpi.net/latest/).
  4. You can use this container to speed up the `pip install` parts of your docker builds. This is done by adding an optional cache of your requirement python packages and speed up docker. The outcome is faster development without breaking builds.
  5. # Getting started
  6. ## Installation
  7. `docker pull muccg/docker-devpi`
  8. ## Quickstart
  9. Start using
  10. ```bash
  11. docker run -d --name devpi \
  12. --publish 3141:3141 \
  13. --volume /srv/docker/devpi:/data \
  14. --env=DEVPI_PASSWORD=changemetoyourlongsecret \
  15. --restart always \
  16. muccg/docker-devpi
  17. ```
  18. *Alternatively, you can use the sample [docker-compose.yml](docker-compose.yml) file to start the container using [Docker Compose](https://docs.docker.com/compose/)*
  19. Please set DEVPI_PASSWORD to a secret otherwise an attacker can *execute arbitrary code*.
  20. ## Client side usage
  21. To use this devpi cache to speed up your dockerfile builds, add use the code below in your dockerfiles. This will add the devpi container an optional cache for pip. The docker containers will try using port 3141 on the docker host first and fall back on the normal pypi servers without breaking the build.
  22. ```Dockerfile
  23. # Install netcat for ip route
  24. RUN apt-get update \
  25. && apt-get install -y netcat \
  26. && rm -rf /var/lib/apt/lists/*
  27. # Use an optional pip cache to speed development
  28. RUN export HOST_IP=$(ip route| awk '/^default/ {print $3}') \
  29. && mkdir -p ~/.pip \
  30. && echo [global] >> ~/.pip/pip.conf \
  31. && echo extra-index-url = http://$HOST_IP:3141/app/dev/+simple >> ~/.pip/pip.conf \
  32. && echo [install] >> ~/.pip/pip.conf \
  33. && echo trusted-host = $HOST_IP >> ~/.pip/pip.conf \
  34. && cat ~/.pip/pip.conf
  35. ```
  36. ## Uploading python packages files
  37. You need to upload your python requirement to get any benefit from the devpi container. You can upload them using the bash code below a similar build environment.
  38. ```bash
  39. pip wheel --download=packages --wheel-dir=wheelhouse -r requirements.txt
  40. pip install "devpi-client>=2.3.0" \
  41. && export HOST_IP=$(ip route| awk '/^default/ {print $3}') \
  42. && if devpi use http://$HOST_IP:3141>/dev/null; then \
  43. devpi use http://$HOST_IP:3141/root/public --set-cfg \
  44. && devpi login root --password=$DEVPI_PASSWORD \
  45. && devpi upload --from-dir --formats=* ./wheelhouse ./packages; \
  46. else \
  47. echo "No started devpi container found at http://$HOST_IP:3141"; \
  48. fi
  49. ```
  50. # Persistence
  51. For devpi to preserve its state across container shutdown and startup you should mount a volume at `/data`. The quickstart command already includes this.
  52. # Security
  53. Devpi creates a user named root by default, its password should be set with DEVPI_PASSWORD environment variable. Please set it, otherwise attackers can *execute arbitrary code* in your application by uploading modified packages.
  54. For additional security the argument `--restrict-modify root` has been added so only the root may create users and indexes.