IntersectMBO / IntersectMBO/cardano-db-sync

Improving Docker Image Creation

Open
#2,012 4 comments 6 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
318
Forks
168
PR merge metrics
No merged PRs in 30d

Description

Currently the Docker image for DB Sync is large, complex, and discourages customization. Given the majority of our users are using the docker image, I would like to revisit this strategy.

## Introduction

Docker images are built from the NixOS module. While this approach does have benefits in reproduceability, it also presents several challenges:

* **Image Size**: Recent releases are 1GB+, even though the binary is less that 100MB
* **Nix specific**: Store paths confuse non-Nix users
* **Bundled Configs**: Included network configuration makes customization difficult

The NixOS module has significant complexity, mostly bash wrappers that inject network-specific configuration from the [Cardano Operations Book](https://book.play.dev.cardano.org/).

A while back, we added [configuration options](https://github.com/IntersectMBO/cardano-db-sync/blob/master/doc/configuration.md) to tune DB Sync to each user's specific needs. While convenient, the batteries-included approach make customization more difficult.

## Proposed Solution

Instead of building the Docker images with Nix, I propose we take a hybrid approach:

1. Build static binaries with Nix
2. Use a simple Dockerfile to copy artifacts to the Docker image

### Example Workflow

```
# Create a static executable
nix build .#cardano-db-sync-linux

# Copy the executable to docker context
cp -L result/bin/cardano-db-sync docker/

# Build the docker image
docker build docker
```

### Configuration Files
The configuration files would **not** be available in the image. Instead, users have two options:

* **Option 1**: Mount the configs in a data volume
* **Option 2**: Create a derived image with the configs baked in

The latest configuration files are available in the [Cardano Operations Book](https://book.play.dev.cardano.org/), which matches the workflow for non-containerized installations.

### Benefits

* **10x smaller images**: 100MB instead of 1GB
* **Standard Docker Experience**: Easier for non-nix users to debug
* **Explicit Configuration**: Straightforward customization for all users

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.