Skip to content
Closed
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
15 changes: 15 additions & 0 deletions packages/edge/infra/client/config/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ pub struct Runner {

pub container_runner_binary_path: Option<PathBuf>,
pub isolate_runner_binary_path: Option<PathBuf>,

/// Custom host entries to append to /etc/hosts in actor containers.
#[serde(default)]
pub custom_hosts: Option<Vec<HostEntry>>,
}

impl Runner {
Expand All @@ -127,6 +131,10 @@ impl Runner {
.clone()
.unwrap_or_else(|| Path::new("/usr/local/bin/rivet-isolate-v8-runner").into())
}

pub fn custom_hosts(&self) -> &[HostEntry] {
self.custom_hosts.as_deref().unwrap_or(&[])
}
}

#[derive(Clone, Deserialize, JsonSchema, Default)]
Expand Down Expand Up @@ -292,3 +300,10 @@ pub enum Addresses {
pub struct Vector {
pub address: String,
}

#[derive(Clone, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
pub struct HostEntry {
pub ip: String,
pub hostname: String,
}
22 changes: 16 additions & 6 deletions packages/edge/infra/client/manager/src/actor/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,7 @@ impl Actor {
);

// hosts file content
let hosts_content = indoc!(
"
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
"
);
let hosts_content = build_hosts_content(ctx);

// Write all files in parallel
tracing::info!(
Expand Down Expand Up @@ -775,6 +770,21 @@ impl Actor {
}
}

fn build_hosts_content(ctx: &Ctx) -> String {
let mut content = indoc!(
"
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
"
).to_string();

for host_entry in ctx.config().runner.custom_hosts() {
content.push_str(&format!("{}\t{}\n", host_entry.ip, host_entry.hostname));
}

content
}

async fn bind_ports_inner(
ctx: &Ctx,
actor_id: Uuid,
Expand Down
Loading