From 31a544305510929c726e2b5e9af6e52e2665bef8 Mon Sep 17 00:00:00 2001 From: Jason Swank Date: Thu, 2 Mar 2023 07:26:07 -0500 Subject: [PATCH] Separate run orchestration from build orchestration --- cli | 26 ++++++++++++++++++++++++++ justfile | 21 --------------------- 2 files changed, 26 insertions(+), 21 deletions(-) create mode 100755 cli diff --git a/cli b/cli new file mode 100755 index 0000000..803be8a --- /dev/null +++ b/cli @@ -0,0 +1,26 @@ +#!/usr/bin/env -S just --working-directory . --justfile + +image := "ghcr.io/jswank/alpine-cli:latest" +n := "alpine-cli" + +# get a bash shell on a temporary container using {{image}} +all: run + +# get a bash shell on a temporary container using {{image}} +run: + @ docker run -ti --rm {{image}} + +# run (or attach to) a perisent container {{n}} +persist: + #!/bin/sh + already_running=$(docker ps --all --filter name={{n}} --format=json | wc -l ) + if [[ $already_running -gt 0 ]]; then + docker start -i {{n}} + else + docker run -ti --name {{n}} {{image}} + fi + +# remove the persistent image +clean: + @ docker rm -f {{n}} >/dev/null 2>&1 + diff --git a/justfile b/justfile index 88f4e12..78353b0 100644 --- a/justfile +++ b/justfile @@ -3,27 +3,6 @@ set dotenv-load image := "ghcr.io/jswank/alpine-cli:latest" n := "alpine-cli" -# get a bash shell on a temporary container using {{image}} -all: run - -# get a bash shell on a temporary container using {{image}} -run: - @ docker run -ti --rm {{image}} - -# run (or attach to) a perisent container {{n}} -persist: - #!/bin/sh - already_running=$(docker ps --all --filter name={{n}} --format=json | wc -l ) - if [[ $already_running -gt 0 ]]; then - docker start -i {{n}} - else - docker run -ti --name {{n}} {{image}} - fi - -# remove the persistent image -clean: - @ docker rm -f {{n}} >/dev/null 2>&1 - # build a new image build: podman build -t {{image}} -f Dockerfile ./ctx