Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/ordo-proto",
"crates/ordo-server",
"crates/ordo-platform",
"crates/ordo-protocol",
"crates/ordo-wasm",
"examples/capability-demo",
]
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.platform
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ RUN apt-get update && apt-get install -y \
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates

# Build release binary (only ordo-platform; other crates build as deps)
# Build release binaries (HTTP API + background worker; other crates build as deps)
RUN --mount=type=cache,id=ordo-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,id=ordo-cargo-git,target=/usr/local/cargo/git,sharing=locked \
--mount=type=cache,id=ordo-rust-target-platform,target=/app/target,sharing=locked \
cargo build --release --package ordo-platform \
&& cp /app/target/release/ordo-platform /tmp/ordo-platform
&& cp /app/target/release/ordo-platform /tmp/ordo-platform \
&& cp /app/target/release/ordo-platform-worker /tmp/ordo-platform-worker

# ── Runtime stage ─────────────────────────────────────────────────────────────
FROM debian:bookworm-slim
Expand All @@ -34,6 +35,7 @@ RUN apt-get update && apt-get install -y \
&& useradd -r -s /bin/false ordo

COPY --from=builder /tmp/ordo-platform /app/ordo-platform
COPY --from=builder /tmp/ordo-platform-worker /app/ordo-platform-worker
COPY crates/ordo-platform/templates /app/templates

USER ordo
Expand Down
25 changes: 25 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,31 @@ services:
retries: 5
start_period: 15s

ordo-platform-worker:
build:
context: .
dockerfile: Dockerfile.platform
restart: unless-stopped
entrypoint: ["/app/ordo-platform-worker"]
environment:
ORDO_DATABASE_URL: "postgresql://ordo:${ORDO_DB_PASSWORD:-ordo_dev_pass}@postgres:5432/ordo_platform"
ORDO_ENGINE_URL: "http://ordo-server:8080"
ORDO_NATS_URL: "nats://nats:4222"
ORDO_NATS_SUBJECT_PREFIX: "ordo.rules"
ORDO_PLATFORM_TEMPLATES_DIR: "/app/templates"
ORDO_JWT_SECRET: "${ORDO_JWT_SECRET:-dev-secret-change-me-in-production-32c}"
ORDO_JWT_EXPIRY_HOURS: "24"
ORDO_LOG_LEVEL: info
depends_on:
nats:
condition: service_started
postgres:
condition: service_healthy
ordo-server:
condition: service_healthy
ordo-platform:
condition: service_healthy

# ── Studio frontend (hot-reload dev server) ───────────────────────────────
ordo-studio:
image: node:22-alpine
Expand Down
2 changes: 2 additions & 0 deletions crates/ordo-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ serde_json = { workspace = true }
serde_yaml = { workspace = true }
colored = { workspace = true }
anyhow = { workspace = true }
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
hashbrown = { workspace = true }
29 changes: 5 additions & 24 deletions crates/ordo-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use anyhow::{Context, Result};
use clap::Args;
use ordo_core::prelude::*;

use crate::runtime::{execute_loaded_rule, load_rule};

#[derive(Args)]
pub struct ExecArgs {
/// Rule file (JSON or YAML)
/// Rule file (JSON, YAML, or .ordo)
#[arg(long, value_name = "FILE")]
rule: String,

Expand All @@ -26,24 +28,15 @@ pub struct ExecArgs {
}

pub fn run(args: ExecArgs) -> Result<()> {
let ruleset = load_ruleset(&args.rule)?;
let rule = load_rule(&args.rule)?;
let mut input = load_input(args.input.as_deref(), args.input_file.as_deref())?;

// Load external data files and inject as $data
if !args.data_files.is_empty() {
inject_external_data(&mut input, &args.data_files)?;
}

let executor = RuleExecutor::new();
let options = if args.trace {
Some(ExecutionOptions::default().trace(true))
} else {
None
};

let result = executor
.execute_with_options(&ruleset, input, options.as_ref())
.map_err(|e| anyhow::anyhow!("Execution error: {}", e))?;
let result = execute_loaded_rule(&rule, input, args.trace)?;

// Output result
let output = serde_json::json!({
Expand All @@ -69,18 +62,6 @@ pub fn run(args: ExecArgs) -> Result<()> {
Ok(())
}

fn load_ruleset(path: &str) -> Result<RuleSet> {
let content =
std::fs::read_to_string(path).with_context(|| format!("Failed to read rule: {}", path))?;
if path.ends_with(".yaml") || path.ends_with(".yml") {
RuleSet::from_yaml_compiled(&content)
.map_err(|e| anyhow::anyhow!("Failed to parse YAML rule: {}", e))
} else {
RuleSet::from_json_compiled(&content)
.map_err(|e| anyhow::anyhow!("Failed to parse JSON rule: {}", e))
}
}

fn load_input(inline: Option<&str>, file: Option<&str>) -> Result<Value> {
if let Some(json) = inline {
let val: Value = serde_json::from_str(json).context("Failed to parse --input JSON")?;
Expand Down
1 change: 1 addition & 0 deletions crates/ordo-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::{Parser, Subcommand};

mod eval;
mod exec;
mod runtime;
mod test_runner;

#[derive(Parser)]
Expand Down
Loading
Loading