Deployment
Docker

Docker Workflow

Manage Docker images with vcpkg dependencies for consistent builds across environments.

Overview

We maintain a cached Docker image (ghcr.io/apstenku123/mlgraph/centroid-deps:latest) that contains all vcpkg packages. This image is automatically built and pushed by the GitHub Actions workflow when Dockerfile.vcpkg changes.

Adding New Packages

Option 1: Incremental Build
Recommended

Use Dockerfile.vcpkg.incremental for faster builds:

# Edit Dockerfile.vcpkg.incremental
docker build -f Dockerfile.vcpkg.incremental -t centroid-deps:new .
# Test the new image
docker run --rm centroid-deps:new vcpkg list

Option 2: Full Rebuild

If incremental build fails or you need to update base dependencies:

  1. Update Dockerfile.vcpkg with all packages
  2. Push to trigger the GitHub Actions workflow
  3. The workflow will build and push the new image

Best Practices

Always start from the existing image when possible to leverage the vcpkg binary cache
Group related packages in a single update to minimize rebuilds
Test locally before pushing to avoid breaking the CI/CD pipeline
Document new dependencies in the Dockerfile comments

Manual Push (Emergency Only)

Warning

Only use manual push if the GitHub Actions workflow fails and you need to deploy urgently.

# Build the image
docker build -f Dockerfile.vcpkg -t ghcr.io/apstenku123/mlgraph/centroid-deps:latest .

# Login to GitHub Container Registry
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin

# Push the image
docker push ghcr.io/apstenku123/mlgraph/centroid-deps:latest

Troubleshooting

Image Pull Failures

  • • Check if you're logged in: docker login ghcr.io
  • • Verify the image exists: docker pull ghcr.io/apstenku123/mlgraph/centroid-deps:latest

Build Failures

  • • Check vcpkg package names: vcpkg search <package>
  • • Verify system dependencies are installed in the RUN apt-get step
  • • Check the vcpkg build logs in the container

Cache Misses

  • • Docker build cache is invalidated if any line in the Dockerfile changes
  • • Use multi-stage builds to preserve cache for unchanged layers

Docker Compose Example

version: '3.8'

services:
  mlgraphd:
    image: mlgraph/daemon:latest
    ports:
      - "50051:50051"  # gRPC
      - "8080:8080"    # REST
      - "9090:9090"    # Admin
    volumes:
      - mlgraph-data:/var/lib/mlgraph
      - ./config:/etc/mlgraph
    environment:
      - MLGRAPH_CLUSTER_MODE=true
      - MLGRAPH_DISCOVERY_METHOD=consul
    depends_on:
      - consul
      - prometheus

  consul:
    image: consul:latest
    ports:
      - "8500:8500"

  prometheus:
    image: prometheus:latest
    ports:
      - "9091:9090"

volumes:
  mlgraph-data: