remove Python from Docker: use Rust CLI for config generation

This commit is contained in:
Adil Hafeez 2026-03-23 05:09:47 +00:00
parent 2e3744fd1a
commit 6cf0c4ff7b
5 changed files with 66 additions and 20 deletions

View file

@ -3,6 +3,7 @@ pub mod cli_agent;
pub mod down;
pub mod init;
pub mod logs;
pub mod render_config;
pub mod self_update;
pub mod up;
pub mod validate;
@ -145,6 +146,10 @@ pub enum Command {
path: String,
},
/// Render config files (used by Docker/supervisord)
#[command(name = "render-config")]
RenderConfig,
/// Update planoai to the latest version
#[command(name = "self-update")]
SelfUpdate {
@ -273,6 +278,7 @@ pub async fn run(cli: Cli) -> anyhow::Result<()> {
list_templates,
}) => init::run(template, clean, output, force, list_templates).await,
Some(Command::Validate { file, path }) => validate::run(file, &path).await,
Some(Command::RenderConfig) => render_config::run().await,
Some(Command::SelfUpdate { version }) => self_update::run(version.as_deref()).await,
}
}

View file

@ -0,0 +1,33 @@
use std::path::Path;
use anyhow::Result;
use crate::config;
/// Render config files for Docker/supervisord use.
/// Reads paths from environment variables (matching the old Python config_generator).
pub async fn run() -> Result<()> {
let config_file =
std::env::var("PLANO_CONFIG_FILE").unwrap_or_else(|_| "/app/plano_config.yaml".to_string());
let schema_file = std::env::var("PLANO_CONFIG_SCHEMA_FILE")
.unwrap_or_else(|_| "plano_config_schema.yaml".to_string());
let template_root = std::env::var("TEMPLATE_ROOT").unwrap_or_else(|_| "./".to_string());
let template_file = std::env::var("ENVOY_CONFIG_TEMPLATE_FILE")
.unwrap_or_else(|_| "envoy.template.yaml".to_string());
let config_rendered = std::env::var("PLANO_CONFIG_FILE_RENDERED")
.unwrap_or_else(|_| "/app/plano_config_rendered.yaml".to_string());
let envoy_rendered = std::env::var("ENVOY_CONFIG_FILE_RENDERED")
.unwrap_or_else(|_| "/etc/envoy/envoy.yaml".to_string());
let template_path = Path::new(&template_root).join(&template_file);
config::validate_and_render(
Path::new(&config_file),
Path::new(&schema_file),
&template_path,
Path::new(&envoy_rendered),
Path::new(&config_rendered),
)?;
Ok(())
}

View file

@ -34,10 +34,9 @@ pub async fn validate_config(plano_config_path: &Path) -> Result<()> {
"-v".to_string(),
format!("{}:/app/plano_config.yaml:ro", abs_path.display()),
"--entrypoint".to_string(),
"python".to_string(),
"planoai".to_string(),
plano_docker_image(),
"-m".to_string(),
"planoai.config_generator".to_string(),
"render-config".to_string(),
];
let output = Command::new(&args[0]).args(&args[1..]).output()?;