# ๐Ÿณ Consolidation: Defining Stable, Self-Contained Methods The CCP platform supports two main approaches for method execution: 1. **Runtime-based methods** (simplified, flexible, ideal for prototyping) 2. **Consolidated methods** (fully packaged, stable, ideal for production) This guide explains how to create a **consolidated method** โ€” where all dependencies and code are bundled into a custom Docker image. --- ## ๐Ÿ’ก Why Consolidate? - Avoid dependency installation at runtime - Ensure reproducibility, even in offline or secure environments - Package complex environments (e.g., Java, R, C++ with specific libs) - Protect source code if needed --- ## ๐Ÿงฑ What You Need To consolidate a method, you must: - Build a custom Docker image with: - Your code already cloned - All dependencies pre-installed - Entrypoint ready to run your method - Push the image to a Docker registry (public or private) - Reference the image in your `method.json` --- ## ๐Ÿณ Docker Image Structure Start from a base image (e.g., `python:3.9`, `debian`, etc.) and: 1. Copy your scripts inside 2. Install any required libraries 3. Define a suitable entrypoint or script ### Example `Dockerfile` (Python) ```Dockerfile FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install -r requirements.txt ENTRYPOINT ["python", "main.py"] ``` Then build and push: ```bash docker build -t registry.org/myproject:1.0 . docker push registry.org/myproject:1.0 ``` --- ## ๐Ÿ“„ Update `method.json` Reference the consolidated image: ```json "ccpimage": { "default": "registry.org/myproject:1.0" } ``` You don't need a deploy script โ€” all preparation is baked into the image. If your entrypoint uses arguments (e.g., `--input /ccp_data/input.txt`), CCP will still inject parameters in the execute script. --- ## ๐Ÿ“ File I/O Rules Still Apply - CCP mounts the `/ccp_data/` folder inside your container - You must **read all inputs** from this directory - You must **write all outputs** to this directory --- ## ๐Ÿงช Testing Your Image Before publishing, always test locally: ```bash docker run -v $(pwd)/testdata:/ccp_data registry.org/myproject:1.0 --input /ccp_data/sample.csv --output /ccp_data/output.txt ``` --- ## ๐Ÿ” Private Registries If you want to use a private Docker image: - You must configure CCP to authenticate with the registry - This currently requires administrator-level integration --- ## โœ… Summary | Feature | Runtime-based | Consolidated | |-------------------------|---------------------|----------------------| | Docker image | CCP-provided | Custom user image | | Dependency install | At runtime | Pre-installed | | Source code | Cloned on the fly | Included in image | | Internet required | Yes | No | | Performance | Slower | Faster, stable | | Use case | Testing, prototyping| Production, secure | --- ## ๐Ÿ“Œ Best Practices - Use tags (e.g., `:1.0`) for immutable images - Keep your Docker images small and clean - Test your method on CCP after publishing the image --- ## ๐Ÿ”— Related Pages - ๐Ÿ”ง [Method development workflow](./01_method_development_flow.md) - ๐Ÿ”ฃ [Structure of method.json](./07_method_json.md) - ๐Ÿง [Docker runtime input](./02_defining_ccpimage.md)