Skip to main content
Ralph provides multiple packaging formats to support different deployment scenarios: Debian packages for Ubuntu, Docker images, and Python packages via setup.py.

Python Package (setup.py)

Package Configuration

Ralph uses setuptools for Python packaging. The main configuration is in setup.py:1:

Requirements

Ralph requires Python 3.10 or higher (setup.py:9):

Entry Points

Ralph provides multiple console scripts and extension points: Console Scripts:
  • ralph - Production server
  • dev_ralph - Development server with additional features
  • test_ralph - Test runner
  • validate_ralph - Cross-validation tool
Extension Points:
  • back_office.transition_action.email_context - Email context for transitions
  • account.views.get_asset_list_class - Custom asset list views
  • ralph.cloud_sync_processors - Cloud synchronization processors
See setup.py:37 for all entry points.

Version Generation

Ralph uses a shell script to generate versions based on git tags:
The version format is YYYYMMDD.PATCH (e.g., 20240315.1).

Debian Packages

Ralph provides official Debian packages for Ubuntu using dh_virtualenv, which packages the application and all dependencies into a self-contained virtualenv.

Why dh_virtualenv?

Ralph’s dependency requirements make traditional Debian packaging challenging. Using dh_virtualenv provides a compromise between package availability and maintenance effort by:
  • Installing all dependencies into a virtualenv
  • Packaging the entire virtualenv as a .deb file
  • Avoiding conflicts with system Python packages
  • Simplifying dependency management

Package Details

Package Name: ralph-core Build Dependencies (debian/control:5):
  • debhelper (>= 9)
  • dh-virtualenv
  • git
  • libmysqlclient-dev
  • python3 (>=3.10)
  • libffi-dev
  • nodejs (>= 22.0.0)
  • npm
Runtime Dependencies (debian/control:10):
  • python3 (>=3.10)
  • libmysqlclient21
  • python3-distutils
  • debconf
Suggested Packages:
  • mysql-server
  • redis

Building Packages

Ralph supports two build modes: snapshot (testing) and release (production).

Building Snapshot Packages

Snapshot packages can be built from any commit for testing purposes:
The built package will be placed in the build/ directory with a name like:
This target:
  1. Builds a Docker container with build dependencies
  2. Generates a snapshot changelog
  3. Builds the package
  4. Copies it to build/
  5. Cleans up the container
See Makefile:33 for implementation.

Building Release Packages

Release packages should be built from tagged commits on the ng branch:
See Makefile:28 for implementation.
Release packages are meant for production use. Always build from tagged commits on the ng branch.

Publishing Packages

Packages are published to packagecloud.io/allegro/ralph by Ralph maintainers. Publishing is triggered automatically when a new GitHub release is created.

Docker Images

Ralph provides multiple Docker images for different purposes.

Available Images

ralph: Main application image
Builds:
  • allegro/ralph:latest
  • allegro/ralph:<VERSION>
ralph-static-nginx: Static files with nginx
  • allegro/ralph-static-nginx:latest
  • allegro/ralph-static-nginx:<VERSION>
inkpy: Additional utility image
  • allegro/inkpy:<VERSION>
See Makefile:40 for build configuration.

Building Snapshot Docker Images

Build snapshot images for testing:
This will:
  1. Build a snapshot Debian package
  2. Build Docker images using the snapshot package
  3. Tag images with snapshot version
See Makefile:57 for implementation.

Publishing Docker Images

See Makefile:73 and Makefile:80 for publishing targets.

Customizing Docker Repository

Set the DOCKER_REPO_NAME variable to push to a different repository:

Package Ecosystem Design

Ralph’s packaging system is designed to be environment-agnostic:

Key Principles

  1. No specific environment required: All operations can be performed using tools a regular Ralph developer already has
  2. Docker-based builds: Everything runs in Docker containers to avoid platform dependencies
  3. Container rebuilds: Containers are rebuilt for each operation to avoid IO performance issues with mounted volumes on certain platforms
  4. Official repository: Packages are published to packagecloud.io, owned by Allegro
  5. GitHub integration: Package publishing is triggered by creating GitHub releases

Why Docker for Building?

Using Docker for package building provides several benefits:
  • Platform independence: Developers on macOS, Windows, or Linux can build packages
  • Consistent environment: Same build environment for all maintainers
  • No system pollution: Build dependencies don’t affect the host system
  • Reproducible builds: Same Dockerfile produces same packages

Makefile Targets

Package Management

Docker Images

Development

See Makefile:1 for all available targets.

Installation from Packages

Installing Debian Package

Installing from PyPI

Installing from Source

Best Practices

  1. Use snapshot packages for testing: Never deploy snapshot packages to production
  2. Verify package contents: After building, inspect the package to ensure all files are included
  3. Test in containers: Use Docker to test packages in clean environments
  4. Follow semantic versioning: Version numbers should reflect the release date and patch level
  5. Document build dependencies: Keep debian/control and setup.py requirements in sync
  6. Clean builds: Always use --force-rm with Docker builds to avoid stale layers

Troubleshooting

Build Fails with Missing Dependencies

Ensure all build dependencies are listed in debian/control. Check the build log for specific missing packages.

Version Mismatch

The version is generated from git tags. Ensure you have the latest tags:

Docker Build Timeout

Increase Docker’s memory and CPU allocation in Docker Desktop settings.

Package Installation Fails

Check that all runtime dependencies are installed: