Add testcontainer for agent image with nginx

This commit is contained in:
GW_MC
2025-12-22 12:54:14 +08:00
parent 61ecd91219
commit 7db23b01df
13 changed files with 589 additions and 78 deletions

View File

@@ -4,6 +4,7 @@ use tokio::signal::unix::{SignalKind, signal};
use crate::{
API_CONFIG_PATH, DB_CONFIG_PATH,
agent::{AgentConfigInfoType, AgentContainerInfo, SOCK_NAME},
db::DBConfigInfoType,
env::{self, EnvFile},
types::{ConfigInfoType, WithContainer, WithoutContainer},
@@ -20,7 +21,7 @@ pub fn to_absolute_path(path: &str) -> PathBuf {
.clean()
}
pub fn write_env_files(db_config: &DBConfigInfoType) {
pub fn write_env_files(db_config: &DBConfigInfoType, agent_config: &Option<AgentConfigInfoType>) {
let api_config_path_absolute = to_absolute_path(API_CONFIG_PATH);
let db_config_path_absolute = to_absolute_path(DB_CONFIG_PATH);
@@ -33,6 +34,20 @@ pub fn write_env_files(db_config: &DBConfigInfoType) {
let mut db_env = api_env.clone();
db_env.file_type = env::EnvFileType::DotEnv;
// agent related env vars
if let Some(agent) = agent_config
&& let ConfigInfoType::Containerized(agent) = agent
{
api_env.write_line(
"AGENT__SOCK__PATH",
format!("{}/{}", &agent.config.agent_config.sock_folder, SOCK_NAME).as_str(),
);
api_env.write_line(
"AGENT__NGINX__CONFIG__DIR",
&agent.config.agent_config.nginx_config_dir,
);
}
let mut api_file =
std::fs::File::create(&api_config_path_absolute).expect("Failed to create API config file");