Coder Social home page Coder Social logo

docker-pypi's Introduction

PyPI Server

This is a simple PyPI server that can be used to host internal packages and versions of packages that are suitable for use with proprietary products.

Usage

If you're not dealing with the Git repo but running the container directly from the Docker index, you can use commands such as the following:

sudo mkdir -p /srv/pypi             # local directory where packages reside
sudo touch /srv/pypi/.htpasswd      # credentials file for adding packages
docker run -t -i --rm \             # remove container when stopped
    -h pypi.local \                 # hostname
    -v /srv/pypi:/srv/pypi:rw \     # host packages from local directory
    -p 8080:80 \                    # expose port 80 as port 8080
    --name pypi \                   # container name
    codekoala/pypi                  # docker repository

Once running, you should be able to visit http://localhost:8080 to see the landing page for your very own PyPI server.

You can add Python packages to the server simply by including the tarballs, zips, wheels, eggs, etc in your /srv/pypi directory.

Configuration

There are some environment variables that may be set to override the default behavior:

  • PYPI_ROOT: path within the container where packages will be stored. Defaults to /srv/pypi.
  • PYPI_PORT: port to bind to receive requests. Defaults to 80.
  • PYPI_PASSWD_FILE: path to authentication file. Defaults to /srv/pypi/.htpasswd.
  • PYPI_OVERWRITE: allow existing packages to be overwritten. Defaults to false.
  • PYPI_AUTHENTICATE: list of (case-insensitive) actions to authenticate. Default to update.
  • PYPI_EXTRA: any additional parameters to pypi-server.

Building Your Own

You can build a new, up-to-date version of the container by cloning the Git repository and using the following command:

make build

This will create a new container that just has the latest version of pypiserver installed and ready to serve packages out of /srv/pypi. To use this container, run:

make run

This will spin up the pypi-server command within container, and it will be exposed on port 8080 on your host system. To test that the container is working, visit http://localhost:8080 in your browser.

Adding Internal Packages

Internal packages may be uploaded to this PyPI server quite easily. The first step is to create a user account:

htpasswd -s /srv/pypi/.htpasswd yourusername

You will probably need to re-run make run each time you update the htaccess file, as it will copy the password file to the correct location before launching the server.

Alternatively, you might be able to just copy the htpasswd file to /srv/pypi/.htpasswd after each change without restarting your PyPI container.

This command (included with Apache on most distributions) will prompt you for a password for yourusername. You should use a more appropriate username, and enter a password that you want to use to "secure" your PyPI uploads. Then edit your ~/.pypirc (create it if necessary), replacing both yourusername and yourpassword with the values used with the htpasswd command:

[distutils]
index-servers =
    pypi
    internal

[pypi]
username:pypiusername
password:pypipassword

[internal]
repository: http://localhost:8080
username:yourusername
password:yourpassword

Next, you should be able to go into any Python project with a valid setup.py file and run:

python setup.py sdist upload -r internal

Assuming the container is online and your credentials are correct, this should add a package with the project contents to the internal PyPI server.

Adding Third Party Packages

Third party packages can be mirrored on the PyPI server by using a command such as:

pip install -d /srv/pypi pkgname

If you have a requirements file for a project's dependencies, you can easily mirror all dependencies by running:

pip install -d /srv/pypi -r requirements.txt

Be careful to use the correct version of pip--sometimes you might want to run pip2 and other times pip3.

Updating Mirrored Packages

You can update the packages mirrored on the internal PyPI server by running:

pypi-server -U /srv/pypi

Each package in the repo will be checked for updates, and instructions for updating the repo with the latest packages will be displayed.

docker-pypi's People

Contributors

beyang avatar bouland avatar codekoala avatar jpds avatar mark86092 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-pypi's Issues

passlib problem during make build

I am trying to get the docker build working. So far I haven't done anything other than a make build to play around with it. The build does not succeed. I assume I can't be doing anything wrong as I haven't changed anything yet. I'm just building the current revision.

Here is the console log all the way from cloning the repo to the error:

vagrant@vagrant-VirtualBox:~/GitRepos$ git clone [email protected]:codekoala/docker-pypi.git
Cloning into 'docker-pypi'...
remote: Counting objects: 54, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 54 (delta 5), reused 0 (delta 0), pack-reused 40
Receiving objects: 100% (54/54), 10.28 KiB | 0 bytes/s, done.
Resolving deltas: 100% (20/20), done.
Checking connectivity... done.
vagrant@vagrant-VirtualBox:~/GitRepos$ cd docker-pypi/
vagrant@vagrant-VirtualBox:~/GitRepos/docker-pypi$ make build
docker build --pull --tag codekoala/pypi:1.2.0 .
Sending build context to Docker daemon 66.56 kB
Step 1/8 : FROM alpine:3.5
3.5: Pulling from library/alpine
627beaf3eaaf: Pull complete 
Digest: sha256:58e1a1bb75db1b5a24a462dd5e2915277ea06438c3f105138f97eb53149673c4
Status: Downloaded newer image for alpine:3.5
 ---> 4a415e366388
Step 2/8 : MAINTAINER Josh VanderLinden <[email protected]>
 ---> Running in fcaa7534b992
 ---> 856530480f33
Removing intermediate container fcaa7534b992
Step 3/8 : RUN apk update && 	apk add py-pip &&     mkdir -p /srv/pypi
 ---> Running in d02e18ea7043
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
v3.5.2-8-g6143df97ca [http://dl-cdn.alpinelinux.org/alpine/v3.5/main]
v3.5.2-7-g487db0f517 [http://dl-cdn.alpinelinux.org/alpine/v3.5/community]
OK: 7959 distinct packages available
(1/12) Installing libbz2 (1.0.6-r5)
(2/12) Installing expat (2.2.0-r0)
(3/12) Installing libffi (3.2.1-r2)
(4/12) Installing gdbm (1.12-r0)
(5/12) Installing ncurses-terminfo-base (6.0-r7)
(6/12) Installing ncurses-terminfo (6.0-r7)
(7/12) Installing ncurses-libs (6.0-r7)
(8/12) Installing readline (6.3.008-r4)
(9/12) Installing sqlite-libs (3.15.2-r0)
(10/12) Installing python2 (2.7.13-r0)
(11/12) Installing py-setuptools (29.0.1-r0)
(12/12) Installing py2-pip (9.0.0-r1)
Executing busybox-1.25.1-r0.trigger
OK: 61 MiB in 23 packages
 ---> d43f6db5d921
Removing intermediate container d02e18ea7043
Step 4/8 : RUN pip install -U passlib pypiserver[cache]==1.2.0
 ---> Running in 86f3479c011a
Collecting passlib
  Could not fetch URL https://pypi.python.org/simple/passlib/: There was a problem confirming the ssl certificate: EOF occurred in violation of protocol (_ssl.c:661) - skipping
  Could not find a version that satisfies the requirement passlib (from versions: )
No matching distribution found for passlib
The command '/bin/sh -c pip install -U passlib pypiserver[cache]==1.2.0' returned a non-zero code: 1
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 1

Should this project be deprecated?

The upstream pypiserver used by this docker configuration has now included official support for docker setups since version 1.2.5. This project remains on version 1.2.1 (I think) and the upstream is now at 1.3.

Perhaps it is appropriate to take some of the measures noted in this blog post to deprecate the project and recommend users switch to the upstream?

If this is an inappropriate suggestion feel free to close without comment....

If you don't have time or interest for the work involved, I'd be happy to write a note at the top of your README, but I don't want to presume.

pypiserver's dev version now falls back to the correct URL

So 3327119 shouldn't be necessary, but for the moment, that would require installing with pip --pre. I'm not sure it's worth reverting the change and uploading a new version to Docker Hub until they don't make an official release- we personally would be happy with either option (have a pre release on Docker Hub or wait until the definitive version).

Feature Request: PKI integration

I'm looking into deploying an internal PyPi server, but to do it right I'd like to have it set up with PKI, and would need to have an HTTPS option which uses an external system to provide the certs to check against. The idea would be that each user and process has their own pair of keys which could be used to control access. I'm not sure that specifically this approach is correct, but I certainly need the end goal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.