From f68b39757ac4b775355ae7e4ce7abe5db64ca7f4 Mon Sep 17 00:00:00 2001 From: saratomaz Date: Tue, 17 Feb 2026 17:06:45 +0000 Subject: [PATCH] Add docker environment for containerized tests --- docker/Dockerfile | 23 ++++++++++++ docker/Dockerfile.dockerignore | 66 ++++++++++++++++++++++++++++++++++ docker/README.md | 59 ++++++++++++++++++++++++++++++ docker/docker-compose.yaml | 30 ++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/Dockerfile.dockerignore create mode 100644 docker/README.md create mode 100644 docker/docker-compose.yaml diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..7d2d10a9d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,23 @@ +# Dockerfile for cardano-node-tests (Antithesis/Moog driver image) +# +# Minimal image: nix is configured and the repo is copied in. +# All heavy setup (cardano binaries, Python venv) happens at runtime +# via regression.sh, which manages its own nix environment through its shebang. +# +# Build and push to GHCR before submitting to Moog: +# docker build -f docker/Dockerfile -t ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest . +# docker push ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest + +FROM nixos/nix:2.25.5 + +ARG GIT_REVISION +ENV GIT_REVISION=${GIT_REVISION} + +RUN mkdir -p /etc/nix && \ + echo "extra-substituters = https://cache.iog.io" >> /etc/nix/nix.conf && \ + echo "extra-trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" >> /etc/nix/nix.conf && \ + echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf && \ + echo "accept-flake-config = true" >> /etc/nix/nix.conf + +WORKDIR /work +COPY . /work/ diff --git a/docker/Dockerfile.dockerignore b/docker/Dockerfile.dockerignore new file mode 100644 index 000000000..ea2e6c752 --- /dev/null +++ b/docker/Dockerfile.dockerignore @@ -0,0 +1,66 @@ +# Ignore unnecessary files during Docker build + +# Git +.git/ +.gitignore + +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info/ +dist/ +build/ +*.egg + +# Virtual environments +.venv/ +venv/ +ENV/ +env/ + +# Testing artifacts +run_workdir/ +.artifacts/ +.cli_coverage/ +.reports/ +allure-results/ +allure-results.tar.xz +testrun-report.* +*.log +*.json.log + +# IDE +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# Nix +result +result-* + +# Documentation +docs/_build/ +*.md + +# Temporary files +*.tmp +*.bak +.DS_Store + +# Scripts output +scripts/destination/ +scripts/destination_working/ + +# Coverage +.coverage +htmlcov/ +cli_coverage.json +requirements_coverage.json + +# CI specific +.bin/ diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..f9b78d17c --- /dev/null +++ b/docker/README.md @@ -0,0 +1,59 @@ +# Docker setup for cardano-node-tests (Antithesis/Moog) + +This directory contains the driver image and compose file for submitting +`cardano-node-tests` to Antithesis via the Moog platform. + +## How it works + +- `Dockerfile` — minimal image: configures Nix and copies the repo into + `/work/`. No binaries are pre-built; `regression.sh` handles all setup at + runtime via its own Nix shebang. Requires `GIT_REVISION` build arg (the + current commit hash) so pytest can identify the revision without a `.git` + directory inside the image. +- `docker-compose.yaml` — single `driver` service for Moog submission. + +## Workflow + +### 1. Build and push the image + +```bash +docker build -f docker/Dockerfile \ + --build-arg GIT_REVISION=$(git rev-parse HEAD) \ + -t ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest . + +docker push ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest +``` + +### 2. Validate the compose locally + +```bash +docker compose -f docker/docker-compose.yaml config +docker compose -f docker/docker-compose.yaml up --build +``` + +### 3. Submit to Moog + +```bash +moog requester create-test \ + --platform github \ + --username saratomaz \ + --repository IntersectMBO/cardano-node-tests \ + --directory ./docker \ + --commit $(git rev-parse HEAD) \ + --try 1 \ + --duration 2 +``` + +## Environment variables + +| Variable | Default | Description | +|-------------------|------------|------------------------------------------| +| `NODE_REV` | `master` | cardano-node git revision | +| `CARDANO_CLI_REV` | (built-in) | cardano-cli revision, empty = use node's | +| `DBSYNC_REV` | (disabled) | db-sync revision, empty = disabled | +| `RUN_TARGET` | `tests` | `tests`, `testpr`, or `testnets` | +| `MARKEXPR` | | pytest marker expression | +| `CLUSTERS_COUNT` | | number of local cluster instances | +| `CLUSTER_ERA` | | e.g. `conway` | +| `PROTOCOL_VERSION`| | e.g. `11` | +| `UTXO_BACKEND` | | e.g. `disk`, `mem` | diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 000000000..06f73d541 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,30 @@ +# Docker Compose for Antithesis/Moog test submission. +# +# Submit to Moog: +# moog requester create-test \ +# --platform github --username \ +# --repository IntersectMBO/cardano-node-tests \ +# --directory ./docker \ +# --commit --try 1 --duration 2 +# +# Validate locally before submitting: +# docker compose -f docker/docker-compose.yaml config +# docker compose -f docker/docker-compose.yaml up --build + +services: + driver: + image: ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest + build: + context: .. + dockerfile: docker/Dockerfile + command: ["/work/.github/regression.sh"] + environment: + - NODE_REV=${NODE_REV:-master} + - CARDANO_CLI_REV=${CARDANO_CLI_REV:-} + - DBSYNC_REV=${DBSYNC_REV:-} + - RUN_TARGET=${RUN_TARGET:-tests} + - MARKEXPR=${MARKEXPR:-} + - CLUSTERS_COUNT=${CLUSTERS_COUNT:-} + - CLUSTER_ERA=${CLUSTER_ERA:-} + - PROTOCOL_VERSION=${PROTOCOL_VERSION:-} + - UTXO_BACKEND=${UTXO_BACKEND:-}