Separate run orchestration from build orchestration

This commit is contained in:
Jason Swank 2023-03-02 07:26:07 -05:00
parent ac0aaec80d
commit 31a5443055
2 changed files with 26 additions and 21 deletions

26
cli Executable file
View File

@ -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

View File

@ -3,27 +3,6 @@ set dotenv-load
image := "ghcr.io/jswank/alpine-cli:latest" image := "ghcr.io/jswank/alpine-cli:latest"
n := "alpine-cli" 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 a new image
build: build:
podman build -t {{image}} -f Dockerfile ./ctx podman build -t {{image}} -f Dockerfile ./ctx