Skip to content

Deployment

Only the first two paths below have been exercised: the local server on a developer machine and the Docker image build in CI. The others are written down but have not been run end to end. Treat them as starting points.

1. Local all-in-one

pip install -e .
blackfox serve

This serves the UI and API on port 7860, with embedded RDF and SQLite.

2. Docker

docker build -t blackfox-kafka-graph .
docker run --rm -p 7860:7860 blackfox-kafka-graph

Mount /data to keep the embedded data between runs:

docker run --rm -p 7860:7860 -v blackfox-data:/data blackfox-kafka-graph

The Container workflow builds this image on every push to main and publishes it to the GitHub Container Registry of the repository.

3. Docker Compose with Fuseki and Cassandra

RDF_BACKEND=fuseki METRIC_BACKEND=cassandra docker compose --profile full up --build

The Compose stack starts:

  • the Black Fox API and UI;
  • Apache Jena Fuseki with TDB2;
  • Apache Cassandra;
  • one-off jobs that load the ontology and apply the CQL migrations.

For a clean rebuild:

docker compose --profile full down -v

The Cassandra adapter reads and writes two of the tables in cassandra/migrations: metric_samples_by_entity_day and latest_metrics_by_tenant. The event, observation and configuration history tables are defined for later work and are not written yet.

4. Static frontend on GitHub Pages

The frontend is static and has no build step. The Pages workflow uploads frontend/ as it is. The workflow is manual, because GitHub Pages is not available for a private repository on the current plan.

  1. In the repository settings, set Pages to deploy from GitHub Actions.
  2. Run the "Deploy GitHub Pages" workflow.
  3. Open "Backend settings" in the deployed UI and enter the backend URL.

Set the backend CORS_ORIGINS to the Pages origin, for example:

https://example.github.io

5. Hugging Face Docker Space

Generate a minimal Space repository:

./scripts/build-hf-space.sh

Push dist/hf-space/ to a Space configured as Docker. The container listens on port 7860.

Suggested variables for a public demo:

APP_ENV=huggingface
RDF_BACKEND=embedded
METRIC_BACKEND=sqlite
SQLITE_PATH=/tmp/blackfox.sqlite3
CORS_ORIGINS=https://www.blackfoxgraph.dev,https://YOUR-NAME-blackfox.hf.space

Space storage is not durable. Use external Fuseki and Cassandra for data you need to keep.

6. AWS App Runner

The root image runs on App Runner. A Terraform starter is in infra/aws/apprunner. It has not been applied as part of validation.

The default App Runner configuration is stateless and suits a demo. For durable data:

  • deploy Fuseki with TDB2 on ECS or EKS with persistent storage, or use another SPARQL service;
  • deploy Cassandra, or adapt the CQL layer for Amazon Keyspaces;
  • use VPC connectivity;
  • load credentials from Secrets Manager;
  • disable public SPARQL or enforce authenticated graph scope;
  • put CloudFront, WAF or API Gateway in front where required.

7. Static frontend on S3 and CloudFront

Upload the contents of frontend/ to an S3 bucket behind CloudFront. The browser stores the selected API URL in local storage.

8. Project site

https://www.blackfoxgraph.dev is a static site on Vercel. vercel.json builds it from this repository:

  • web/index.html and web/assets/ are the homepage;
  • MkDocs builds docs/ into web/docs/;
  • frontend/ is copied to web/app/ and runs with its bundled sample data.

Build it locally with make site. The generated web/docs/ and web/app/ directories are not committed.

Environment variables

See .env.example. The main controls for a deployment:

RDF_BACKEND=embedded|fuseki
METRIC_BACKEND=sqlite|cassandra
CORS_ORIGINS=https://frontend.example
ENABLE_PUBLIC_SPARQL=false
STRICT_EXTERNAL_STORES=true