Перейти к содержимому

DevOps and infrastructure ​

MVP decision

RayScan will run on Hetzner Cloud. Terraform is the source of truth for infrastructure; CI/CD builds and delivers API and Worker images. Version 0.1.0 uses virtual servers and one Docker container per scan. Kubernetes remains a later option.

This is a target design, not a deployed production environment.

Production image (SECU-65)

The image ships the API process in the existing DigitalOcean App Platform service, next to the static sites; PostgreSQL and S3-compatible storage are external managed services. After the deploy, Nginx on api. proxies only /v1, POST /mcp (MCP over Streamable HTTP for agents) and /healthz; the worker channel /v1/internal/* stays closed. Nothing is live until the human deploys it. The Hetzner and Terraform design on this page remains a target. The scan worker and the Agentfy integration are not deployed.

Prepared: app server on Hetzner (SECU-105) ​

Prepared, not live

Production still runs on DigitalOcean App Platform and deploys on every push to main. The Hetzner app server below exists as code, Terraform and a runbook only; it serves production after the human applies Terraform, makes the first deploy and switches DNS. Until App Platform is shrunk, it stays the rollback target.

text
Internet ──443/80──▶ Caddy (TLS for 5 hosts) ──▶ same image: Nginx → website, app, admin, docs, API
                                                       │
Private network 10.20.0.0/16                           ├── PostgreSQL (external managed)
  worker 10.20.1.20 ──http://10.20.1.10──▶ Caddy ──────┘   └── Object Storage
       (worker channel paths only)
  • Server. CX23 in fsn1 with a permanent IPv4 and a firewall for TCP 22 (key only), 80 and 443: module terraform/modules/hcloud/app-server, environment terraform/environments/hetzner/prod. Secrets live only in /etc/securify/app.env on the server.
  • Caddy. Runs in a container in front of the same image as App Platform. It starts with internal certificates (SECURIFY_TLS=internal) and switches to Let's Encrypt (SECURIFY_TLS=acme) after DNS points at the server. The image trusts the client address only from Caddy (REAL_IP_SOURCE=caddy, REAL_IP_FROM); without these variables it keeps the App Platform behaviour (do-connecting-ip).
  • Private network. The app server is 10.20.1.10, the existing scan worker 10.20.1.20. After the cutover the worker reaches the API at http://10.20.1.10; the worker channel /v1/internal/worker/ answers 404 on the public entry.
  • Delivery. .github/workflows/app-deploy.yml builds ghcr.io/agentfy/securify:<sha> on every push to main; it deploys over SSH with docker/hetzner/release.sh (health check, rollback to the previous tag) only once the human sets APP_DEPLOY_ENABLED=true. App Platform keeps deploying the same commit.
  • Runbook. terraform/environments/hetzner/prod/README.md: first launch, cutover, rollback to App Platform and, later, shrinking App Platform to the docs mirror (.do/app.docs-only.yaml); the mirror https://security-docs-casvk.ondigitalocean.app/ stays.

The single app server above is narrower than the target topology below (no Load Balancer, PostgreSQL stays an external managed service).

MVP topology ​

text
Internet
   │
   ▼
Hetzner Load Balancer
   │
   ▼
API / MCP Server
   │
   ├── PostgreSQL
   ├── job queue
   ├── Object Storage
   └── Worker Server (reaches only the API's internal worker channel)
          │
          └── one Docker container per scan
                 ├── archive validation
                 ├── safe extraction
                 ├── malware and code scanning
                 └── report → Worker → API → Object Storage

Hetzner Cloud provides Cloud Servers, private networks, Firewalls, Volumes and Load Balancers. Cloud Servers, Private Networks, Firewalls

Components ​

API server ​

The API handles users, teams, projects, connections, queue operations, scan status and MCP access. Only the protected HTTP entry point is public. PostgreSQL and Worker have no public ports.

The current API is one local process: read-only MCP over stdio and, on a 127.0.0.1 HTTP listener, the app's /v1, the internal worker channel and POST /mcp. The production image (SECU-65) runs the same process behind Nginx on api.: after the deploy it exposes only /v1, POST /mcp and /healthz; the internal worker channel stays closed and no worker is deployed. The layout below is the target.

Worker server ​

The Worker owns Docker Engine. For each job it claims the job from the API, downloads the snapshot and its manifest from the API, checks the archive digest, creates a temporary workspace, starts a resource-limited container, sends the accepted report back to the API and removes the workspace. It talks only to the API's internal worker channel (/v1/internal/worker/…, bearer WORKER_TOKEN): it holds no database or Object Storage credentials, and the API chooses where a report is stored. The scanner container receives no Docker socket, customer credentials, platform keys or database access. Its network is disabled by default.

The channel and the worker command exist in code (SECU-29) and run on the local stand only; no production API process or Worker server is deployed yet.

PostgreSQL ​

PostgreSQL stores users, teams, projects, connections, snapshots, scans, findings, remediations and audit events. Archives and large reports stay in Object Storage.

Object Storage ​

Hetzner Object Storage is S3-compatible and stores objects as immutable data, which fits snapshots and audit reports. Object Storage documentation

text
securify-quarantine  # received archives before validation
securify-snapshots   # verified website snapshots
securify-reports     # reports and tool output
securify-backups     # RayScan backups

All buckets are private. The API issues temporary download links when a customer needs a report.

Network isolation ​

text
Public zone:    Load Balancer → API
Private zone:   API ↔ PostgreSQL, API ↔ Object Storage, Worker → API (internal worker channel)
Worker zone:    Docker jobs without inbound connections or Docker socket
  • PostgreSQL accepts connections only from API.
  • Object Storage credentials stay on the API server; the Worker downloads snapshots and uploads reports through the API.
  • Worker has no public inbound ports.
  • FTP/SFTP credentials never enter the agent context or scanner container.
  • Each job has a separate temporary directory and resource limits.
  • Secrets are not stored in Git or Terraform state.

Terraform layout ​

text
infra/
└── terraform/
    ├── modules/          # network, firewall, server, database, worker, storage, load balancer
    └── environments/     # dev, stage, prod

Terraform creates networks, servers, Firewalls, Volumes, Load Balancers, buckets, SSH keys and labels. It does not run scans, perform migrations, store FTP passwords or control Agentfy. Applications are delivered by CI/CD.

Terraform state is remote and protected. CI serialises applies so concurrent runs cannot change the same environment. Secrets come from CI secret storage or a dedicated secret manager, never from committed .tfvars files.

Deployment and backups ​

GitHub Actions tests the code, builds immutable API and Worker images, scans them and publishes them to a registry. Servers pull a specific image digest; latest is not used in production.

dev, stage and prod use separate Hetzner Projects, networks, databases and buckets. The minimum backup policy is a daily PostgreSQL backup, encrypted copies of critical reports and configuration, a private backup bucket, retention limits and regular restore tests. Server snapshots are useful for recovery but do not replace database and Object Storage backups.

Evolution ​

0.1.0: one API server, one Worker server, PostgreSQL, Object Storage and Docker isolation per scan.

0.2.0: multiple Workers, prioritised queue, metrics and logs, automatic scaling and Kubernetes only if measured workload justifies the operational cost.

Implementation order ​

  1. Create infra/terraform and the dev environment.
  2. Define the network, Firewall, SSH access and a test Worker.
  3. Add private buckets and PostgreSQL.
  4. Build API and Worker images in CI.
  5. Add stage and test restore procedures.
  6. Create production only after the pilot path is repeatable.

RayScan · Документация проекта · Прототип → MVP