Merge pull request #210 from pypiserver/docker-updates

Dockerfile & doc updates
This commit is contained in:
Matthew Planchard 2018-06-26 22:14:31 -05:00 committed by GitHub
commit c621d45474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 116 additions and 19 deletions

@ -35,3 +35,7 @@ __pycache__/
/.cache/
/.settings/
Dockerfile
venv
.venv
.vscode
.idea

@ -1,5 +1,7 @@
sudo: false
sudo: required
language: python
services: docker
python:
- 2.7
- 3.4
@ -12,6 +14,7 @@ install:
- pip install -U setuptools pip sphinx tox tox-travis
script:
- ./bin/test-docker.sh
- ./bin/test_standalone.sh
- tox
- ./bin/check_readme.sh

@ -12,4 +12,4 @@ AUTHORS
awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' |
sort -rn | cut -d\ -f2-
to sort them by the numbers of commits.
to sort them by the numbers of commits.

@ -1,15 +1,28 @@
Changelog
=========
Next Release
------------------
- MAINT: Remove broken downloads badge (thanks @hugovk, #209)
- ENH: Improved Dockerfile and ``docker-compose`` example, docs for using
the docker image, automatic docker builds
1.2.2 (2018-06-12)
------------------
- FIX: update fallback URL to https://pypi.org/simple since pypi.python.org
has shut down
- FIX: updated tests to use ``Popen`` rather than ``pip.main()`` given its
removal in pip version 10.0
- DOC: scrubbed docs of links to pypi.python.org
- DEPRECATION: Drop support for Python 3.3 (tahnks @hugovk, #198)
1.2.1 (2017-11-29)
------------------

@ -1,17 +1,25 @@
FROM python:3.4
FROM python:3.6-alpine
# Build
COPY . /code
WORKDIR /code
RUN python setup.py install
RUN pip install passlib
WORKDIR /
RUN rm -rf /pypiserver
# Data Directory
RUN mkdir -p /data/packages
RUN adduser -S -u 9898 pypiserver && \
addgroup -S -g 9898 pypiserver && \
python setup.py install && \
pip install passlib && \
cd / && \
rm -rf /code && \
mkdir -p /data/packages && \
chown -R pypiserver:pypiserver /data/packages && \
# Set the setgid bit so anything added here gets associated with the
# pypiserver group
chmod g+s /data/packages
VOLUME /data/packages
USER pypiserver
WORKDIR /data
EXPOSE 8080
ENTRYPOINT ["pypi-server"]
CMD ["-p", "80", "packages"]
EXPOSE 80
ENTRYPOINT ["pypi-server", "-p", "8080"]
CMD ["packages"]

@ -332,6 +332,45 @@ use it like this::
pypiupload requirements requirements.txt -i pypi_local
Using the Docker Image
======================
Starting with version 1.2.3, official Docker images are built for each
push to master, each dev, alpha, or beta release, and each final release.
The most recent full release will always be available under the tag ``latest``,
and the current master branch will always be available under the tag
``master``.
To run the most recent release of ``pypiserver`` with Docker, simply::
docker run pypiserver/pypiserver:latest
This starts ``pypiserver`` serving packages from the ``/data/packages``
directory inside the container, listening on the container port 8080.
The container takes all the same arguments as the normal ``pypi-server``
executable, with the exception of the internal container port (``-p``),
which will always be 8080.
Of course, just running a container isn't that interesting. To map
port 80 on the host to port 8080 on the container::
docker run -p 80:8080 pypiserver/pypiserver:latest
You can now access your ``pypiserver`` at ``localhost:80`` in a web browser.
To serve packages from a directory on the host, e.g. ``~/packages``::
docker run -p 80:8080 -v ~/packages:/data/packages pypiserver/pypiserver:latest
To authenticate against a local ``.htaccess`` file::
docker run -p 80:8080 -v ~/.htaccess:/data/.htaccess pypiserver/pypiserver:latest -P .htaccess packages
You can also specify ``pypiserver`` to run as a Docker service using a
composefile. An example composefile is `provided <docker-compose.yml>`_.
Alternative Installation methods
================================
When trying the methods below, first use the following command to check whether

19
bin/test-docker.sh Executable file

@ -0,0 +1,19 @@
#!/usr/bin/env sh
# Perform some simple validation to make sure the Docker image works
# Should be run from the repo root.
set -xe # exit on any error, show debug output
docker build . -t pypiserver:test
docker run pypiserver:test --help
CONTAINER_ID=$(docker run -d -p 8080:8080 pypiserver:test)
sleep 5 # give the contaienr some time to get going
# Ensure our home page is returning something
curl localhost:8080 | grep -q "pypiserver"
docker container stop "$CONTAINER_ID"

@ -1,7 +1,18 @@
pypiserver:
image: pypiserver
volumes:
- /var/pypiserver:/data
command: -p 80 -P /data/.htaccess -a update,download,list /data/packages
ports:
- "8080:80"
---
########################################################################
# pypiserver docker-compose example
########################################################################
version: "3"
services:
pypiserver:
image: pypiserver:latest
volumes:
# Mount local /tmp/pypiserver to /data in container
- /tmp/pypiserver:/data
# Use an .htaccess file to control access, serve packages from
# /tmp/pypiserver/packages (/data/packages in the container)
command: -P /data/.htaccess -a update,download,list /data/packages
ports:
- "80:8080"