docker: add platform dependent fixes for docker
Fixes
@@ -9,6 +9,12 @@ VOLUME_OPTIONS=""
CAPABILITIES=""
RELEASE="testing"
+if [ "$(basename "${DOCKER}")" = "podman" ]; then
+ IS_DOCKER=false
+else
+ IS_DOCKER=true
+fi
+
if [ "${OSTYPE}" == "linux-gnu" ] && [ "$(basename "${DOCKER}")" = "podman" ]; then
CAPABILITIES="--cap-add=CAP_SYS_PTRACE";
fi
@@ -22,7 +28,24 @@ IMAGE_NAME="simde-dev-${RELEASE}"
# (Re)build image
# We only do this if the current image is older than a week (if jq is installed)
BUILD_IMAGE=auto
-if command -v jq >/dev/null; then
+if [ "$IS_DOCKER" = true ]; then
+ BUILD_CUTOFF_TIME="$(expr $(date +%s) - \( 60 \* 60 \* 24 \* 7 \))"
+ DATE="$(docker images "${IMAGE_NAME}" --format '{{ .CreatedAt }}' | awk '{ print $1 " " $2 }')"
+
+ if [ "$(uname)" == "Darwin" ]; then
+ CURRENT_IMAGE_CREATED="$(date -jf "%Y-%m-%d %H:%M:%S" "$DATE" +%s)"
+ else
+ CURRENT_IMAGE_CREATED="$(date +"%s" -d "$DATE")"
+ fi
+
+ if [ -z "${CURRENT_IMAGE_CREATED}" ]; then
+ BUILD_IMAGE=y
+ elif [ ${CURRENT_IMAGE_CREATED} -lt ${BUILD_CUTOFF_TIME} ]; then
+ BUILD_IMAGE=y
+ else
+ BUILD_IMAGE=n
+ fi
+elif command -v jq >/dev/null; then
BUILD_CUTOFF_TIME="$(expr $(date +%s) - \( 60 \* 60 \* 24 \* 7 \))"
CURRENT_IMAGE_CREATED="$(${DOCKER} images "${IMAGE_NAME}" --format json | jq '.[].Created')"
