add xtask to push docker image
This commit is contained in:
parent
0b02efc752
commit
60bd5acd35
@ -1,8 +1,8 @@
|
||||
FROM rust:1.80
|
||||
|
||||
COPY . /usr/app
|
||||
COPY battlesnake/ /usr/app
|
||||
WORKDIR /usr/app
|
||||
|
||||
RUN cargo install --path battlesnake
|
||||
RUN cargo install --path .
|
||||
|
||||
CMD ["battlesnake"]
|
||||
|
@ -21,6 +21,7 @@ fn try_main() -> Result<(), DynError> {
|
||||
match task.as_deref() {
|
||||
Some("local") => local()?,
|
||||
Some("local2") => local2()?,
|
||||
Some("docker") => docker()?,
|
||||
_ => print_help(),
|
||||
}
|
||||
Ok(())
|
||||
@ -32,6 +33,8 @@ fn print_help() {
|
||||
|
||||
local runs the snake on a local game
|
||||
local2 runs the snake twice on a local game
|
||||
|
||||
docker package docker image and upload to docker.mkaenner.de/snake
|
||||
"
|
||||
)
|
||||
}
|
||||
@ -120,6 +123,21 @@ fn run_snake(port: u16) -> Result<Child, DynError> {
|
||||
}
|
||||
}
|
||||
|
||||
fn docker() -> Result<(), DynError> {
|
||||
if !Command::new("docker")
|
||||
.current_dir(project_root())
|
||||
.args(["build", ".", "-t", "docker.mkaenner.de/snake"])
|
||||
.status()?
|
||||
.success()
|
||||
{
|
||||
Err("Build of docker image failed")?;
|
||||
}
|
||||
Command::new("docker")
|
||||
.args(["push", "docker.mkaenner.de/snake"])
|
||||
.status()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn project_root() -> PathBuf {
|
||||
Path::new(&env!("CARGO_MANIFEST_DIR"))
|
||||
.ancestors()
|
||||
|
Loading…
Reference in New Issue
Block a user