sauber-devpi is a fully Dockerized solution for setting up and running a DevPI server. It handles multiple user and index creation, and it is designed to be easily deployed on cloud platforms like Railway.
- Automated DevPI server setup
- Multiple user and index creation based on environment variables
- Fully Dockerized for easy deployment
- Multi-stage Docker build for optimized image sizes
- Helper scripts for easy interaction with the DevPI server
sauber-devpi/
βββ src/
β βββ sauber_devpi/
β βββ __init__.py
β βββ main.py # Handles DevPI server setup, user, and index creation
β βββ docker_setup.py # Installs poetry dependencies in Docker
βββ scripts/
β βββ export_env.sh # Exports environment variables
β βββ devpi_kaosmaps.sh # Helper script for interacting with the kaosmaps index
β βββ docker_run.sh # Script to run the Docker container
β βββ docker_build.sh # Script to build the Docker image
β βββ devpi_admin.sh # Script for admin login to DevPI
βββ pyproject.toml # Poetry configuration for dependencies
βββ Dockerfile # Docker configuration for multi-stage builds
βββ .env # Environment variable definitions for the DevPI setup
βββ .gitignore # Git ignore file (assumed to exist)
βββ README.md # Project documentation
- Docker
- Poetry (for local development)
The .env file provides an easy way to configure the DevPI setup. Here are the variables that can be configured:
DEVPI_SERVER: The URL of the DevPI server (default:http://localhost:3141).DEVPI_USER: The username for the admin DevPI user (default:admin).DEVPI_PASSWORD: The password for the admin DevPI user.DEVPI_KAOSMAPS_USER: The username for the kaosmaps DevPI user (default:kaosmaps).DEVPI_KAOSMAPS_PASSWORD: The password for the kaosmaps DevPI user.DEVPI_INDEX: The name of the DevPI index to be created (default:dev).
To customize these, modify the .env file before building and running the container.
If you'd like to run the DevPI server locally without Docker, follow these steps:
-
Clone the repository: git clone cd sauber-devpi
-
Install dependencies with poetry: poetry install
-
Run the DevPI server: poetry run python -m sauber_devpi.main
To build the Docker image, run the following command in the root directory:
docker build -t sauber-devpi .
Once the image is built, you can run the container using the following command:
./scripts/docker_run.sh
This script will:
- Load the environment variables from the
.envfile. - Run the Docker container, exposing port
3141on the host machine.
This script exports the environment variables defined in the .env file. It's used by other scripts to ensure they have access to the correct configuration.
Usage:
source ./scripts/export_env.sh
This script builds the Docker image for the sauber-devpi project.
Usage:
./scripts/docker_build.sh
This script runs the Docker container, loading environment variables from the .env file and exposing port 3142.
Usage:
./scripts/docker_run.sh
This script logs in to the DevPI server as the admin user, creates the admin index if it doesn't exist, and optionally uploads packages.
Usage:
./scripts/devpi_railway_admin.sh
This script helps interact with the kaosmaps index on the Railway-deployed server. It:
- Logs in to the kaosmaps user
- Creates the kaosmaps index if it doesn't exist
- Optionally uploads packages to the index if a
pyproject.tomlfile is present
Usage:
./scripts/devpi_railway_kaosmaps.sh
This script logs in to the local DevPI server as the admin user.
Usage:
./scripts/devpi_local_admin.sh
This script helps interact with the kaosmaps index on the local DevPI server. It:
- Logs in to the kaosmaps user
- Creates the kaosmaps index if it doesn't exist
- Uploads packages to the index if a
pyproject.tomlfile is present
Usage:
./scripts/devpi_local_kaosmaps.sh
This script deploys the project to Railway using the Railway CLI.
Usage:
./scripts/dev/railway_deploy.sh
Note: Make sure to run source ./scripts/export_env.sh before using the DevPI-related scripts to ensure the necessary environment variables are set. For the Railway deployment script, ensure you have the Railway CLI installed and are logged in.
After the container is running, you can configure pip to use the DevPI server for package installations:
pip install --index-url http://localhost:3141/<DEVPI_USER>/<DEVPI_INDEX>/simple <package-name>
This project is configured for easy deployment to Railway:
- Fork this repository to your GitHub account.
- Connect your forked repository to Railway.
- Set the following environment variables in Railway:
DEVPI_USERDEVPI_PASSWORDDEVPI_KAOSMAPS_USERDEVPI_KAOSMAPS_PASSWORDDEVPI_INDEX
- Railway will automatically deploy your app when you push changes to the main branch.
For manual deployments, you can use the Railway CLI:
railway upFeel free to open issues or submit pull requests if you'd like to improve this project.
This project is licensed under the MIT License.