-
Notifications
You must be signed in to change notification settings - Fork 120
/
build.rs
51 lines (42 loc) · 1.46 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Builds a container with a bunch of extra options for testing
use bollard::image::BuildImageOptions;
use bollard::Docker;
use std::collections::HashMap;
use futures_util::stream::StreamExt;
#[tokio::main]
async fn main() {
let docker = Docker::connect_with_socket_defaults().unwrap();
let mut build_image_args = HashMap::new();
build_image_args.insert("dummy", "value");
let mut build_image_labels = HashMap::new();
build_image_labels.insert("maintainer", "somemaintainer");
let build_image_options = BuildImageOptions {
dockerfile: "Dockerfile",
t: "bollard-build-example",
extrahosts: Some("myhost:127.0.0.1"),
remote:
"https://raw.githubusercontent.com/docker-library/openjdk/master/11/jdk/slim/Dockerfile",
q: false,
nocache: false,
cachefrom: vec![],
pull: true,
rm: true,
forcerm: true,
memory: Some(120000000),
memswap: Some(500000),
cpushares: Some(2),
cpusetcpus: "0-3",
cpuperiod: Some(2000),
cpuquota: Some(1000),
buildargs: build_image_args,
shmsize: Some(1000000),
squash: false,
labels: build_image_labels,
networkmode: "host",
platform: "linux/x86_64",
};
let mut image_build_stream = docker.build_image(build_image_options, None, None);
while let Some(msg) = image_build_stream.next().await {
println!("Message: {:?}", msg);
}
}