Add labels, update just helper
This commit is contained in:
parent
79b4b4521b
commit
e069b580b7
@ -1,4 +1,10 @@
|
||||
FROM alpine:3
|
||||
FROM docker.io/library/alpine:3
|
||||
|
||||
LABEL org.opencontainers.image.title=jswank/alpine-cli \
|
||||
org.opencontainers.image.description="A minimal image for running Linux CLI utilities" \
|
||||
org.opencontainers.image.url=https://git.sr.ht/~jswank/alpine-cli \
|
||||
org.opencontainers.image.authors="Jason Swank" \
|
||||
org.opencontainers.image.licenses=MIT
|
||||
|
||||
RUN apk -U --no-cache add \
|
||||
doas doas-sudo-shim \
|
||||
|
||||
57
bin/cli
57
bin/cli
@ -1,25 +1,66 @@
|
||||
#!/usr/bin/env -S just --working-directory . --justfile
|
||||
|
||||
image := "ghcr.io/jswank/alpine-cli:latest"
|
||||
n := "cli"
|
||||
n := "alpine-cli"
|
||||
|
||||
# run
|
||||
# Invoke the 'run' recipe
|
||||
default: run
|
||||
|
||||
# run a temporary container based on {{image}}
|
||||
# Usage: run
|
||||
#
|
||||
# Start a shell in an ephemeral container.
|
||||
#
|
||||
# Examples:
|
||||
# cli run
|
||||
#
|
||||
# Run an ephemeral container.
|
||||
@run:
|
||||
podman run -ti --rm {{image}}
|
||||
podman run -ti --userns=keep-id --rm {{image}}
|
||||
|
||||
# run (or attach to) a persistent container {{n}}
|
||||
# Usage: persist
|
||||
#
|
||||
# Start a shell in a persistent container.
|
||||
#
|
||||
# Examples:
|
||||
# cli persist
|
||||
#
|
||||
# Run (or attach to) a persistent container
|
||||
persist:
|
||||
#!/bin/sh
|
||||
if [ $(podman ps --all --filter name="{{n}}" -q | wc -l) -gt 0 ]; then
|
||||
if [ $(podman ps --all --filter name="^{{n}}$" -q | wc -l) -gt 0 ]; then
|
||||
podman start -i -a {{n}}
|
||||
else
|
||||
podman run -ti --name {{n}} {{image}}
|
||||
podman run -ti --userns=keep-id --name {{n}} {{image}}
|
||||
fi
|
||||
|
||||
# remove the persistent container
|
||||
# Remove the persistent container
|
||||
@clean:
|
||||
podman rm -f {{n}} >/dev/null 2>&1
|
||||
|
||||
# Usage: save [new_image_name]
|
||||
#
|
||||
# Sometimes you want a quick snapshot of your work in progress. Use this target
|
||||
# to create an image based on the running container.
|
||||
#
|
||||
# Examples:
|
||||
# cli save foo` - saves the current (persistent) container as a new image
|
||||
# named "foo"
|
||||
# ` cli save - saves the current (persistent) container as a new
|
||||
# default image
|
||||
#
|
||||
# Save the running container as a new image
|
||||
save i=image:
|
||||
podman commit -q {{n}} {{i}} >/dev/null 2>&1
|
||||
|
||||
# Remove a running container, and run the default recipe
|
||||
@restart: clean default
|
||||
|
||||
# Display this listing. Detailed help is available with 'help recipe_name'.
|
||||
help recipe="help":
|
||||
#!/bin/sh
|
||||
if [ "{{recipe}}" = "help" ]; then
|
||||
just --list --justfile {{justfile()}}
|
||||
else
|
||||
grep -B 32 -E '^@?{{recipe}}\s?.*:' {{justfile()}} \
|
||||
| tac | awk 'NR==1 {print; next}; !/^#/{exit}1;' | tac
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user