-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will make easier for us to change the implmentation later.
- Loading branch information
1 parent
7e09c15
commit 6b9db6b
Showing
2 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::process::{Command, Stdio}; | ||
|
||
pub struct DockerClient {} | ||
|
||
impl DockerClient { | ||
pub fn build_image(ruby_version: &str, rails_version: &str) -> Command { | ||
let mut command = Command::new("docker"); | ||
|
||
command | ||
.arg("build") | ||
.arg("--build-arg") | ||
.arg(format!("RUBY_VERSION={}", ruby_version)) | ||
.arg("--build-arg") | ||
.arg(format!("RAILS_VERSION={}", rails_version)) | ||
.arg("-t") | ||
.arg(format!("rails-new-{}-{}", ruby_version, rails_version)) | ||
.arg("-") | ||
.stdin(Stdio::piped()); | ||
|
||
command | ||
} | ||
|
||
pub fn run_image(ruby_version: &str, rails_version: &str, args: Vec<String>) -> Command { | ||
let binding = std::env::current_dir().unwrap(); | ||
let current_dir = binding.to_str().unwrap(); | ||
|
||
let mut command = Command::new("docker"); | ||
|
||
command | ||
.arg("run") | ||
.arg("-v") | ||
.arg(format!("{}:{}", current_dir, current_dir)) | ||
.arg("-w") | ||
.arg(current_dir) | ||
.arg(format!("rails-new-{}-{}", ruby_version, rails_version)) | ||
.arg("rails") | ||
.arg("new") | ||
.args(args); | ||
|
||
command | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters