datahaven/.github/workflows
Steve Degosserie 9a5404de82
refactor: Consolidate and optimize Docker image architecture (#233)
## Overview

This PR consolidates and optimizes the Docker build system, reducing
redundancy and improving CI/CD performance. The changes eliminate
duplicate Dockerfiles, introduce a flexible build template, and optimize
release builds to reuse CI artifacts.

## Changes Summary

### 🐳 Docker Images Restructured

**Before:** 5 Dockerfiles with significant overlap
**After:** 4 focused images + 1 utility

#### Final Structure:

1. **`operator/Dockerfile`**  Updated
   - **Standard operator image** for CI and release builds
   - Minimal node image (accepts pre-built binaries)
   - GHCR: `ghcr.io/datahaven-xyz/datahaven/datahaven` (CI)
   - DockerHub: `datahavenxyz/datahaven` (releases)

2. **`docker/datahaven-build.Dockerfile`** (moved from
`operator/Dockerfile`)
   - Full source-to-binary build for manual releases
   - DockerHub: `datahavenxyz/datahaven:{label}`
   - Supports custom RUSTFLAGS and fast-runtime feature
   - Only used for manual workflow_dispatch builds

3. **`docker/datahaven-production.Dockerfile`** (kept)
   - Binary builder for CPU-specific releases
   - Used by build-prod-binary workflow template
   - Supports custom target-cpu flags

4. **`docker/datahaven-dev.Dockerfile`**  NEW (local dev only)
   - **FOR LOCAL DEVELOPMENT/TROUBLESHOOTING ONLY**
   - Includes debug tools: gdb, strace, vim, sudo
   - Extra dependencies: librocksdb-dev, curl
   - RUST_BACKTRACE enabled by default
   - **DO NOT USE for CI or production builds**

5. **`test/docker/crossbuild-mac-libpq.dockerfile`** (kept)
   - Utility for macOS → Linux cross-compilation

#### Removed (Redundant):
-  `docker/datahaven.Dockerfile` → replaced by operator/Dockerfile
-  `test/docker/datahaven-node-local.dockerfile` → replaced by
datahaven-dev.Dockerfile

---

### 🔄 Workflow Improvements

#### Enhanced `publish-docker` Template
- Supports both GHCR and DockerHub registries
- Flexible inputs: dockerfile, context, build-args, cache scope
- Auto-generates OCI-compliant labels
- Reduces code duplication (~70 lines → ~15 per workflow)

#### Refactored CI Pipeline
- **`docker-build-ci`**: Builds `operator/Dockerfile` → GHCR for CI/E2E
testing
- **`docker-build-release`**: Builds `operator/Dockerfile` → DockerHub
(main branch only)
- Both CI and release workflows now use the same minimal operator image
- Release builds **reuse CI binaries** instead of rebuilding from source

#### Optimized Release Workflow
The `task-docker-release` workflow now has dual modes:

**Mode 1: `workflow_call` (CI - main pushes)**
-  Reuses binary from CI's build-operator task
-  Uses lightweight `operator/Dockerfile`
-  Tags: `latest`, `sha-{short}`
-  **Fast**: ~5 minutes (vs ~30 min previously)

**Mode 2: `workflow_dispatch` (Manual)**
-  Full source build with `datahaven-build.Dockerfile`
-  Custom branch and label selection
-  Optional fast-runtime feature
-  Tags: `PROD-{label}` or user-defined

---

### 🔧 Additional Optimizations

- Copy libpq5 from builder stage instead of reinstalling (smaller,
faster)
- Remove redundant protobuf-compiler package (use protoc v21.12
directly)
- Standardize user UID to 1000 across all runtime images
- Consistent OCI labeling and metadata

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-15 01:33:20 +02:00
..
actions fix: fix RPC for storage hub (#190) 2025-09-27 19:03:32 +02:00
CI.yml refactor: Consolidate and optimize Docker image architecture (#233) 2025-10-15 01:33:20 +02:00
enforce-pr-labels.yml ci: Enforce PR labels for breaking changes and auditability (#169) 2025-09-17 14:21:33 +02:00
task-build-operator.yml refactor: Consolidate and optimize Docker image architecture (#233) 2025-10-15 01:33:20 +02:00
task-check-metadata.yml ci: 👷 Add CI to check PAPI metadata (#107) 2025-06-19 19:12:04 -03:00
task-docker-ci.yml refactor: Consolidate and optimize Docker image architecture (#233) 2025-10-15 01:33:20 +02:00
task-docker-release.yml refactor: Consolidate and optimize Docker image architecture (#233) 2025-10-15 01:33:20 +02:00
task-e2e.yml ci: fix snowbridge relay volume leak (#168) 2025-09-16 22:18:52 +00:00
task-foundry-tests.yml test: ️ CI Refactor (#59) 2025-05-06 20:20:02 +00:00
task-moonwall-tests.yml test: Integrate moonwall (#185) 2025-09-30 14:47:39 +00:00
task-publish-binary.yml fix: Use DH self-hosted runners for the Publish Draft Binary gh action (#183) 2025-09-23 00:05:06 +02:00
task-publish-runtime.yml fix: 🔧 Use standard Github runners for the publish runtime task (#225) 2025-10-11 10:37:19 +02:00
task-rust-lint.yml feat: storage hub client (#149) 2025-09-10 08:15:27 +02:00
task-rust-tests.yml ci: remove nextest archive (#164) 2025-09-16 13:44:16 +02:00
task-ts-build.yml test: New CLI functions (#84) 2025-05-22 20:02:12 +00:00
task-ts-lint.yml test: ️ CI Refactor (#59) 2025-05-06 20:20:02 +00:00
weekly-audit.yml test: ️ CI Refactor (#59) 2025-05-06 20:20:02 +00:00