feat: fix container recreate
All checks were successful
Container build / container-build (push) Successful in 3m21s
All checks were successful
Container build / container-build (push) Successful in 3m21s
This commit is contained in:
parent
a0b65c856d
commit
3560f348a7
@ -26,4 +26,3 @@ COPY --chown=user:user config/nvim/lazyvim.json /home/user/.config/nvim/lazyvim.
|
|||||||
# === setup container ===
|
# === setup container ===
|
||||||
ENV TZ="Europe/Amsterdam"
|
ENV TZ="Europe/Amsterdam"
|
||||||
VOLUME /home/user/.local /home/user/.cache
|
VOLUME /home/user/.local /home/user/.cache
|
||||||
CMD ["bash", "-l"]
|
|
||||||
|
37
enter.sh
37
enter.sh
@ -3,19 +3,14 @@
|
|||||||
# enter.sh v1.0; job79 #
|
# enter.sh v1.0; job79 #
|
||||||
# Enter into an existing or new dev container and #
|
# Enter into an existing or new dev container and #
|
||||||
# automatically handle dev container updates. #
|
# automatically handle dev container updates. #
|
||||||
# #
|
|
||||||
# TODO #
|
|
||||||
# ----------------------------------------------- #
|
|
||||||
# remove --security-opt label=disable #
|
|
||||||
# configurable mount directories #
|
|
||||||
# =============================================== #
|
# =============================================== #
|
||||||
set -e
|
set -eu
|
||||||
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-○}" "$1"; }
|
log() { printf '\e[%sm%s\e[0m %s\n' "${3:-36}" "${2:-○}" "$1"; }
|
||||||
|
arg() { echo -n " $@"; }
|
||||||
|
|
||||||
# run_args returns the arguments required for the podman run
|
# run_args returns the arguments required for the podman run
|
||||||
# command.
|
# command.
|
||||||
run_args() {
|
run_args() {
|
||||||
arg() { echo -n " $@"; }
|
|
||||||
arg "--name $name"
|
arg "--name $name"
|
||||||
|
|
||||||
# Disable some security settings to make it possible to
|
# Disable some security settings to make it possible to
|
||||||
@ -54,31 +49,23 @@ fetch=false
|
|||||||
|
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--image | -i)
|
--image | -i) shift && image="$1" ;;
|
||||||
shift
|
--fetch | -f) fetch=true ;;
|
||||||
image="$1"
|
-*) log "unknown argument '$1'" 'x' 31 ;;
|
||||||
;;
|
*) name="$1" ;;
|
||||||
--name | -n)
|
|
||||||
shift
|
|
||||||
name="$1"
|
|
||||||
;;
|
|
||||||
--fetch | -f)
|
|
||||||
fetch=true
|
|
||||||
;;
|
|
||||||
*) log "unknown argument '$1'" 'x' 31 ;;
|
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if "$fetch" = true ] || [ "$(podman container inspect "$name" -f {{.State.Running}})" = 'false' ]; then
|
if [ "$fetch" = true ] || [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ]; then
|
||||||
log "fetching updates..."
|
log "fetching updates..."
|
||||||
if [ "$(podman pull -q "$image")" != "$(podman container inspect "$name" -f {{.Image}})" ]; then
|
if [ "$(podman pull -q "$image")" != "$(podman container inspect "$name" -f {{.Image}} 2>&1)" ]; then
|
||||||
log "new container image downloaded" '✓' 32
|
log "container image downloaded" '✓' 32
|
||||||
podman container rm -f -t 1 "$name" 1>/dev/null
|
podman container rm -f -t 1 "$name" 1>/dev/null
|
||||||
podman run -it $(run_args) "$image"
|
podman run -td $(run_args) "$image"
|
||||||
exit
|
else
|
||||||
|
log "no updates available" '✓' 32
|
||||||
fi
|
fi
|
||||||
log "no updates available" '✓' 32
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
podman start "$name" 1>/dev/null
|
podman start "$name" 1>/dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user