Skip to content

Commit

Permalink
chore: add update task to update run-bakery
Browse files Browse the repository at this point in the history
  • Loading branch information
koehlma committed Dec 6, 2023
1 parent e6b6a38 commit acaa5c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions crates/rugpi-bakery/assets/run-bakery
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -euo pipefail

DOCKER=${DOCKER:-"docker"}
DOCKER_FLAGS=${DOCKER_FLAGS:-""}

RUGPI_DEV=${RUGPI_DEV:-"false"}

if [ "${RUGPI_DEV}" = "false" ]; then
DOCKER_FLAGS="${DOCKER_FLAGS} --pull always"
RUGPI_VERSION=${RUGPI_VERSION:-"v0"}
else
RUGPI_VERSION=${RUGPI_VERSION:-"dev"}
fi

RUGPI_BAKERY_IMAGE=${RUGPI_BAKERY_IMAGE:-"ghcr.io/silitics/rugpi-bakery:${RUGPI_VERSION}"}

exec $DOCKER run --rm --privileged \
$DOCKER_FLAGS \
-v "$(pwd)":/project \
-v /dev:/dev \
"${RUGPI_BAKERY_IMAGE}" \
"$@"
5 changes: 5 additions & 0 deletions crates/rugpi-bakery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum Task {
Bake(BakeTask),
/// Spawn a shell in the Rugpi Bakery Docker container.
Shell,
Update,
}

fn main() -> Anyhow<()> {
Expand All @@ -54,6 +55,10 @@ fn main() -> Anyhow<()> {
let zsh_prog = CString::new("/bin/zsh")?;
nix::unistd::execv::<&CStr>(&zsh_prog, &[])?;
}
Task::Update => {
println!("Update Rugpi Bakery...");
std::fs::write("run-bakery", include_str!("../assets/run-bakery"))?;
}
}
Ok(())
}
2 changes: 1 addition & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() -> anyhow::Result<()> {
"docker",
"build",
"-t",
"ghcr.io/silitics/rugpi-bakery:latest",
"ghcr.io/silitics/rugpi-bakery:dev",
"-f",
"docker/Dockerfile.rugpi-bakery",
"."
Expand Down

0 comments on commit acaa5c6

Please sign in to comment.