Skip to content

Commit 63c4f21

Browse files
committed
Use specific docker platform if specified
1 parent 927195d commit 63c4f21

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

catalog/tempo/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use serde::Deserialize;
2-
use spec::{Arg, Babel, ComputeResource, Deployment, DeploymentExtension, Manifest, Pod, Spec, Volume};
2+
use spec::{
3+
Arg, Babel, ComputeResource, Deployment, DeploymentExtension, Manifest, Platform, Pod, Spec,
4+
Volume,
5+
};
36

47
#[derive(Default, Clone)]
58
pub enum Chains {
@@ -37,7 +40,7 @@ impl ComputeResource for Tempo {
3740

3841
fn spec(&self, _chain: Chains) -> eyre::Result<Pod> {
3942
let node = Spec::builder()
40-
.image("ghcr.io/tempo-xyz/tempo")
43+
.image("ghcr.io/tempoxyz/tempo")
4144
.tag("1.0.1")
4245
.volume(Volume {
4346
name: "data".to_string(),
@@ -77,6 +80,7 @@ impl ComputeResource for Tempo {
7780
preferred: 9000,
7881
},
7982
)
83+
.platform(Platform::LinuxAmd64)
8084
.with_babel(Babel::new(
8185
"ethereum",
8286
Arg::Ref {

crates/runtime-docker-compose/src/compose.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ pub(crate) struct DockerComposeService {
4949
#[serde(default)]
5050
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
5151
pub depends_on: BTreeMap<String, DependsOn>,
52+
53+
#[serde(default)]
54+
#[serde(skip_serializing_if = "Option::is_none")]
55+
pub platform: Option<String>,
5256
}
5357

5458
#[derive(Default, Debug)]

crates/runtime-docker-compose/src/runtime.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bollard::Docker;
22
use bollard::query_parameters::CreateImageOptions;
33
use futures_util::future::join_all;
44
use futures_util::stream::StreamExt;
5-
use spec::{File, Manifest};
5+
use spec::{File, Manifest, Platform};
66
use std::collections::{BTreeMap, HashMap, HashSet};
77
use std::net::TcpListener;
88
use std::process::{Command, Stdio};
@@ -360,6 +360,15 @@ impl DockerRuntime {
360360
labels.insert("metrics".to_string(), format!("{}", metrics_port.port));
361361
}
362362

363+
let platform = if let Some(platform) = spec.platform {
364+
let str = match platform {
365+
Platform::LinuxAmd64 => "linux/amd64".to_string(),
366+
};
367+
Some(str)
368+
} else {
369+
None
370+
};
371+
363372
let service = DockerComposeService {
364373
command,
365374
entrypoint: spec.entrypoint.clone(),
@@ -370,6 +379,7 @@ impl DockerRuntime {
370379
volumes: service_volumes,
371380
networks: vec!["test".to_string()],
372381
depends_on: init_services,
382+
platform,
373383
};
374384

375385
let service_name = format!("{}-{}", pod_name, spec_name);

crates/spec/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ pub struct Spec {
222222
pub artifacts: Vec<Artifacts>,
223223
pub ports: Vec<Port>,
224224
pub volumes: Vec<Volume>,
225+
pub platform: Option<Platform>,
225226
pub extensions: HashMap<String, serde_json::Value>,
226227
}
227228

@@ -237,6 +238,7 @@ pub struct SpecBuilder {
237238
ports: Vec<Port>,
238239
volumes: Vec<Volume>,
239240
extensions: HashMap<String, serde_json::Value>,
241+
platform: Option<Platform>,
240242
}
241243

242244
impl Spec {
@@ -245,6 +247,11 @@ impl Spec {
245247
}
246248
}
247249

250+
#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
251+
pub enum Platform {
252+
LinuxAmd64,
253+
}
254+
248255
impl SpecBuilder {
249256
pub fn image<S: Into<String>>(mut self, image: S) -> Self {
250257
self.image = Some(image.into());
@@ -327,6 +334,11 @@ impl SpecBuilder {
327334
self
328335
}
329336

337+
pub fn platform(mut self, platform: Platform) -> Self {
338+
self.platform = Some(platform);
339+
self
340+
}
341+
330342
pub fn get_extension<R: serde::de::DeserializeOwned>(
331343
&self,
332344
name: String,
@@ -360,6 +372,7 @@ impl SpecBuilder {
360372
ports: ports,
361373
volumes: self.volumes,
362374
extensions: self.extensions,
375+
platform: self.platform,
363376
}
364377
}
365378
}

0 commit comments

Comments
 (0)