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
52
53
54
55
56
57
58
59
60
61
62
use tokio::process::Command;
use std::str;
use console::style;
pub async fn process_docker_build(project_id: &str, service_name: &str) {
let gcr_url = String::from("eu.gcr.io/") + project_id + "/" + service_name;
let output = Command::new("docker")
.args(&["build", ".", "-t", &gcr_url])
.output()
.await;
println!("output = {:?}", output);
}
pub async fn process_docker_push(project_id: &str, service_name: &str) {
let gcr_url = String::from("eu.gcr.io/") + project_id + "/" + service_name;
let output = Command::new("docker")
.args(&["push", &gcr_url])
.output()
.await;
println!("output = {:?}", output);
}
pub async fn process_docker_psql() {
let output = Command::new("docker")
.args(&[
"run",
"--rm",
"-d",
"--name",
"epics-psql",
"-p",
"5432:5432",
"-v",
"postgres-tmp:/home/postgresql/data",
"-e",
"POSTGRES_USER=postgres",
"-e",
"POSTGRES_PASSWORD=postgres",
"-e",
"POSTGRES_DB=epics_db",
"postgres:14.3-alpine",
])
.output()
.await;
match &output {
Ok(val) => {
let err = str::from_utf8(&val.stderr);
let out = str::from_utf8(&val.stdout);
match out.unwrap() {
"" => println!("{:?}", err.unwrap().trim()),
_ => {
println!(
"✅ {} {}",
style("PostgreSQL Container Created:").white().bold(),
style(out.unwrap().trim()).white().bold()
);
}
}
},
Err(err) => println!("error = {:?}", err)
}
}