Add labels, update just helper
This commit is contained in:
parent
79b4b4521b
commit
e069b580b7
14
Dockerfile
14
Dockerfile
@ -1,9 +1,15 @@
|
|||||||
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 \
|
RUN apk -U --no-cache add \
|
||||||
doas doas-sudo-shim \
|
doas doas-sudo-shim \
|
||||||
bash less \
|
bash less \
|
||||||
coreutils grep gawk perl
|
coreutils grep gawk perl
|
||||||
|
|
||||||
RUN adduser -h /home/cli -s /bin/bash -D cli cli && \
|
RUN adduser -h /home/cli -s /bin/bash -D cli cli && \
|
||||||
addgroup cli wheel && \
|
addgroup cli wheel && \
|
||||||
|
|||||||
59
bin/cli
59
bin/cli
@ -1,25 +1,66 @@
|
|||||||
#!/usr/bin/env -S just --working-directory . --justfile
|
#!/usr/bin/env -S just --working-directory . --justfile
|
||||||
|
|
||||||
image := "ghcr.io/jswank/alpine-cli:latest"
|
image := "ghcr.io/jswank/alpine-cli:latest"
|
||||||
n := "cli"
|
n := "alpine-cli"
|
||||||
|
|
||||||
# run
|
# Invoke the 'run' recipe
|
||||||
default: run
|
default: run
|
||||||
|
|
||||||
# run a temporary container based on {{image}}
|
# Usage: run
|
||||||
@run:
|
#
|
||||||
podman run -ti --rm {{image}}
|
# Start a shell in an ephemeral container.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# cli run
|
||||||
|
#
|
||||||
|
# Run an ephemeral container.
|
||||||
|
@run:
|
||||||
|
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:
|
persist:
|
||||||
#!/bin/sh
|
#!/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}}
|
podman start -i -a {{n}}
|
||||||
else
|
else
|
||||||
podman run -ti --name {{n}} {{image}}
|
podman run -ti --userns=keep-id --name {{n}} {{image}}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove the persistent container
|
# Remove the persistent container
|
||||||
@clean:
|
@clean:
|
||||||
podman rm -f {{n}} >/dev/null 2>&1
|
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