Docker
Docker is a popular tool for packaging applications and their dependencies into containers. Containers ensure your application runs consistently across different systems. Ordeq applications can be easily packaged and run in Docker containers. This guide shows how to package a simple hello-world pipeline in a Docker container and run it.
Making your project runnable
First, make your project runnable by creating an entrypoint.
In Python, this is typically a __main__.py
script at the source root.
For example, your project structure might look like:
src
├── __init__.py
├── __main__.py
└── pipeline.py
For this guide, pipeline.py
contains a simple node:
from ordeq import node
@node
def hello_world() -> None:
print("Hello, World!")
The content of __main__.py
depends on how you want to run your application.
Ordeq supports two main approaches:
- Using the command line interface (
ordeq-cli-runner
package) - Running programmatically (using the
ordeq
package)
Use the CLI if you need to choose pipelines dynamically. If your application always runs the same pipeline, running programmatically is simpler.
Reference implementations:
from ordeq_cli_runner import main
if __name__ == "__main__":
# Invoke the CLI of ordeq-cli-runner
main()
import pipeline
from ordeq import run
if __name__ == "__main__":
# Run the pipeline programmatically
run(pipeline)
This entrypoint makes your project runnable in any environment, not just containers. For more details, see this guide.
Packaging your application
Next, package your application in a Docker container. Start by choosing a base image. We recommend following the uv Docker guide for setting up your base image and dependencies.
Here’s an example Dockerfile using a uv base image:
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
# Copy the source code into the image
ADD . /app
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
# Sync the project into a new environment
WORKDIR app
RUN uv sync
# Set the entrypoint to run the Ordeq application
ENTRYPOINT ["uv", "run", "src/app/__main__.py", "run"]
You can inspect the example project here.
Build the Docker image with:
docker build -t app .
This creates a Docker image named app
containing your Ordeq application. The user only needs the image to run the application; they don’t need to know anything about Ordeq or Python.
Running your application
To run the application in a container:
docker run app pipeline:hello_world
This command starts a container from the app
image and runs the hello_world
node in the pipeline
pipeline. You can replace pipeline:hello_world
with any arguments your entrypoint script accepts.
The output for our example should be:
Hello, World!
Docker configuration
Real-world applications often require additional configuration when running in Docker containers, such as networking, configuration, and secrets. Most of these are specific to your application, not to Ordeq. See the Docker documentation for more details.
Questions, issues, or remarks
If you have any questions, issues or remarks on integrating Ordeq with Docker, please reach out by opening an issue on GitHub.