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 ===
|
||||
ENV TZ="Europe/Amsterdam"
|
||||
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 into an existing or new dev container and #
|
||||
# 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"; }
|
||||
arg() { echo -n " $@"; }
|
||||
|
||||
# run_args returns the arguments required for the podman run
|
||||
# command.
|
||||
run_args() {
|
||||
arg() { echo -n " $@"; }
|
||||
arg "--name $name"
|
||||
|
||||
# Disable some security settings to make it possible to
|
||||
@ -54,32 +49,24 @@ fetch=false
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
--image | -i)
|
||||
shift
|
||||
image="$1"
|
||||
;;
|
||||
--name | -n)
|
||||
shift
|
||||
name="$1"
|
||||
;;
|
||||
--fetch | -f)
|
||||
fetch=true
|
||||
;;
|
||||
*) log "unknown argument '$1'" 'x' 31 ;;
|
||||
--image | -i) shift && image="$1" ;;
|
||||
--fetch | -f) fetch=true ;;
|
||||
-*) log "unknown argument '$1'" 'x' 31 ;;
|
||||
*) name="$1" ;;
|
||||
esac
|
||||
shift
|
||||
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..."
|
||||
if [ "$(podman pull -q "$image")" != "$(podman container inspect "$name" -f {{.Image}})" ]; then
|
||||
log "new container image downloaded" '✓' 32
|
||||
if [ "$(podman pull -q "$image")" != "$(podman container inspect "$name" -f {{.Image}} 2>&1)" ]; then
|
||||
log "container image downloaded" '✓' 32
|
||||
podman container rm -f -t 1 "$name" 1>/dev/null
|
||||
podman run -it $(run_args) "$image"
|
||||
exit
|
||||
fi
|
||||
podman run -td $(run_args) "$image"
|
||||
else
|
||||
log "no updates available" '✓' 32
|
||||
fi
|
||||
fi
|
||||
|
||||
podman start "$name" 1>/dev/null
|
||||
podman exec -it "$name" bash -l
|
||||
|
Loading…
Reference in New Issue
Block a user