This commit is contained in:
Jason Swank 2023-03-16 12:21:36 -04:00
parent c14c57e182
commit ac6aa468f5
5 changed files with 49 additions and 32 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

View File

@ -7,11 +7,29 @@ images.
## Quickstart ## Quickstart
```console ```console
$ docker run -ti --rm ghcr.io/jswank/alpine-cli docker run -ti --rm ghcr.io/jswank/alpine-cli
~ $ ^D
exit
$ just
~ $ ^D ~ $ ^D
exit exit
``` ```
A script, using [casey/just](https://github.com/casey/just') is in [bin/cli](bin/cli).
It can be used to quickly start an ephemeral (or persistent) container:
```console
bin/cli
~ $ ^D
exit
bin/cli persist
~ $ ls
~ $
exit
podman cp foo.json alpine-cli:/home/cli
bin/cli persist
~ $ ls
foo.json
~ $
exit
```

25
bin/cli Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env -S just --working-directory . --justfile
image := "ghcr.io/jswank/alpine-cli:latest"
n := "cli"
# run
default: run
# run a temporary container based on {{image}}
@run:
podman run -ti --rm {{image}}
# run (or attach to) a perisent container {{n}}
persist:
#!/bin/sh
if [ $(podman ps --all --filter name="{{n}}" -q | wc -l) -gt 0 ]; then
podman start -i -a {{n}}
else
podman run -ti --name {{n}} ghcr.io/jswank/alpine-cli:latest
fi
# remove the persistent image
clean:
@ podman rm -f {{n}} >/dev/null 2>&1

26
cli
View File

@ -1,26 +0,0 @@
#!/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

@ -1,7 +1,6 @@
set dotenv-load set dotenv-load
image := "jswank/alpine-cli:latest" image := "jswank/alpine-cli:latest"
n := "alpine-cli"
# build a new image # build a new image
build: build: