summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2024-02-12 03:33:46 -0500
committerJesse Luehrs <doy@tozt.net>2024-02-12 03:33:46 -0500
commitda20ca3a6f90b64e82f7873c432f01164816ac6e (patch)
treea8ba22567af27b34e9eb1114c4c76f178fdc82ac
parent81bc45debcd734d60581fd6ed420fdb50990e19e (diff)
downloadconf-da20ca3a6f90b64e82f7873c432f01164816ac6e.tar.gz
conf-da20ca3a6f90b64e82f7873c432f01164816ac6e.zip
improve the podman wrapper scripts
-rwxr-xr-xlocal/.bin/reply28
-rwxr-xr-xlocal/.bin/smt23
2 files changed, 41 insertions, 10 deletions
diff --git a/local/.bin/reply b/local/.bin/reply
index 250a93b..412189f 100755
--- a/local/.bin/reply
+++ b/local/.bin/reply
@@ -1,10 +1,28 @@
#!/bin/sh
set -eu
-podman images | grep -q localhost/reply || cat <<EOF | podman build -t reply -f -
+DOCKERFILE="$(cat <<EOF
FROM docker.io/debian:stable-slim
-RUN sed -i 's/stable\/updates/stable-security\/updates/' /etc/apt/sources.list
-RUN apt-get update && apt-get install -y --no-install-recommends cpanminus make gcc libreadline-dev
-RUN cpanm -n Reply B::Keywords Data::Dump Carp::Always Term::ReadLine::Gnu
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ cpanminus \
+ make \
+ gcc \
+ libreadline-dev
+RUN cpanm -n \
+ Reply \
+ B::Keywords \
+ Data::Dump \
+ Carp::Always \
+ Term::ReadLine::Gnu
EOF
-podman run --rm -itv /home/doy/.replyrc:/root/.replyrc reply reply "$@"
+)"
+IMAGE="$(basename "$0"):$(echo "$DOCKERFILE" | sha256sum | cut -d' ' -f1)"
+
+if [ -z "$(podman images -q "$IMAGE")" ]; then
+ echo "$DOCKERFILE" | podman build -t "$IMAGE" -f - .
+fi
+
+podman run --rm -it \
+ -v "$HOME"/.replyrc:/root/.replyrc \
+ "$IMAGE" \
+ reply "$@"
diff --git a/local/.bin/smt b/local/.bin/smt
index ad3f459..446197d 100755
--- a/local/.bin/smt
+++ b/local/.bin/smt
@@ -1,9 +1,22 @@
#!/bin/sh
set -eu
-podman images | grep -q localhost/smt || cat <<EOF | podman build -t smt -f -
-FROM docker.io/alpine:latest
-RUN apk add perl make
-RUN env PERL_MM_USE_DEFAULT=1 perl -MCPAN -e'install Games::SMTNocturne::Demons'
+DOCKERFILE="$(cat <<EOF
+FROM docker.io/debian:stable-slim
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ cpanminus \
+ make \
+ gcc \
+ libreadline-dev
+RUN cpanm -n Games::SMTNocturne::Demons
EOF
-podman run --rm smt smt "$@"
+)"
+IMAGE="$(basename "$0"):$(echo "$DOCKERFILE" | sha256sum | cut -d' ' -f1)"
+
+if [ -z "$(podman images -q "$IMAGE")" ]; then
+ echo "$DOCKERFILE" | podman build -t "$IMAGE" -f - .
+fi
+
+podman run --rm -it \
+ "$IMAGE" \
+ smt "$@"