Skip to content

Commit

Permalink
Merge pull request EpicsDAO#19 from JonasCir/fix-zapp-docker-psql
Browse files Browse the repository at this point in the history
fix local docker psql execution
  • Loading branch information
POPPIN-FUMI committed Oct 2, 2022
2 parents 54365d8 + ab616e4 commit 798797a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/docker/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ use crate::style_print::*;
use std::process::Command;
use std::str;


pub fn process_psql_docker() {
create_docker_network();
process_docker_psql("zapp-psql");
}

pub fn process_docker_build(project_id: &str, service_name: &str, gcr_region: &str) {
let gcr_url = String::from(gcr_region) + "/" + project_id + "/" + service_name;
let output = Command::new("docker")
Expand All @@ -18,7 +24,7 @@ pub fn process_docker_push(project_id: &str, service_name: &str, gcr_region: &st
println!("output = {:?}", output);
}

pub fn create_docker_network() {
fn create_docker_network() {
let _output = Command::new("docker")
.args(&["network", "create", "zapp"])
.output();
Expand All @@ -32,7 +38,7 @@ pub fn process_docker_restart() {
let _output2 = Command::new("zapp").args(&["docker", "psql"]).output();
}

pub fn process_docker_psql(service_name: &str) {
fn process_docker_psql(service_name: &str) {
let underscored_name = service_name.to_string().replace("-", "_");
let container_name = String::from(service_name) + "-psql";
let db_name = String::from("POSTGRES_DB=") + &underscored_name + "_db";
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ fn main() {
let docker_cmd = docker.command.unwrap_or(DockerCommands::Help);
match docker_cmd {
DockerCommands::Psql => {
let gcp = get_gcp();
create_docker_network();
process_docker_psql(&gcp.service_name);
process_psql_docker();
}
DockerCommands::Build => {
let gcp = get_gcp();
Expand Down Expand Up @@ -225,6 +223,8 @@ fn main() {
}
}



pub fn get_gcp() -> GcpConfig {
let file_name = "gcp_config.json";
let f = File::open(file_name).unwrap();
Expand Down

0 comments on commit 798797a

Please sign in to comment.