Devpi is self-hosted pypi repository. This setup provides simple Docker environment. Just clone & go!
Docker and docker compose installed. See:
Unless you add user to docker
group you have to prepend docker
and tools commands with sudo
like
$ sudo docker compose up
$ sudo bin/start
$ git clone [email protected]:x2es/docker-devpi.git
$ cd docker-devpi
$ docker compose up
Swarm doesn't accept pull_policy
option in docker-compose.yml
hence it have to be commented.
(once) $ docker swarm init
$ cd docker-devpi
$ docker build . -t devpi
$ bin/start
...
$ bin/stop
Unstopped Docker services will start at next boot.
See content of bin/start
and bin/stop
scripts for details and docker service --help
Setup repository "local"
(prj-dir) $ poetry config repositories.local http://localhost:3141/user/private
Publish
(prj-dir) $ poetry build
(prj-dir) $ poetry publish -r local -u user -p userpassword
$ pip install -i http://localhost:3141/user/private package-name
Create staging repositories in front of pypi.org
See docker-compose.yml
as reference.
Container will be initialized on first run:
- Once
USER_NAME=
andUSER_PASSWORD=
given: user will be created - Once
INDEX_NAME=
given: index will be created forUSER_NAME=
orroot
By default devpi-init
will initialize root/pypi
repository and sync index with pypi.org.
You may provide --no-root-pypi
using INIT_EXTRA_ARGS=
variable to avoid it.
Provided docker-compose.yml
persists server data using local volume devpi_server
.
As alternative you may mount local directory to container's SERVER_DIR
It's safe to recreate container once volume used.
In order to reset persisted data
docker volume rm devpi_server
Spawn shell or invoke command in the running container (when started either by docker-compose up
or swarm)
$ bin/console
$ bin/console devpi_server
$ bin/console devpi_server /usr/bin/env python3
$ bin/console devpi_server pip install foo
(swarm only)
Check the output logs
$ bin/log
$ bin/log -f
$ bin/log devpi_server
$ bin/log devpi_server -f
see bin/log content for details
$ bin/start && bin/wait-container devpi_server && bin/console devpi_server ls
$ bin/start && bin/log -f
$ docker service ps --no-trunc devpi_server
or
$ (Ubuntu) journalctl -u docker.service
see https://stackoverflow.com/a/45373282/983232
CAUTION it will cleanup all data related to devpi
.
$ ( set -x; docker compose rm; docker volume rm devpi_server; docker image rm devpi )
or
$ ( set -x; sudo docker compose rm; sudo docker volume rm devpi_server; sudo docker image rm devpi )