diff --git a/Dockerfile b/Dockerfile index 44bfaa6..6cb51f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ ARG ALPINE_VERSION=3.21 FROM alpine:${ALPINE_VERSION} +# Re-declare after FROM — build ARGs don't persist across FROM ARG SUPERCRONIC_VERSION=0.2.33 -# TARGETARCH is auto-set by buildx per platform: "amd64", "arm64", etc. ARG TARGETARCH RUN apk add --no-cache docker-cli ADD https://github.com/aptible/supercronic/releases/download/v${SUPERCRONIC_VERSION}/supercronic-linux-${TARGETARCH} \ /usr/local/bin/supercronic -RUN chmod +x /usr/local/bin/supercronic +RUN chmod 755 /usr/local/bin/supercronic # Match GID to your host's docker group. Check with: stat -c '%g' /var/run/docker.sock ARG DOCKER_GID=999 diff --git a/build.sh b/build.sh index fdc928a..67b17bf 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -IMAGE="${IMAGE:-docker-pruner}" +IMAGE="${IMAGE:-registry.domandoman.xyz/cannibal}" TAG="${TAG:-latest}" DOCKER_GID="${DOCKER_GID:-$(stat -c '%g' /var/run/docker.sock)}" SUPERCRONIC_VERSION="${SUPERCRONIC_VERSION:-0.2.33}" @@ -25,4 +25,5 @@ docker buildx build \ --build-arg SUPERCRONIC_VERSION="${SUPERCRONIC_VERSION}" \ --build-arg DOCKER_GID="${DOCKER_GID}" \ --tag "${IMAGE}:${TAG}" \ + --push \ . diff --git a/docker-compose.yml b/docker-compose.yml index 0003c7f..408bf2d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,8 @@ services: cannibal: - image: cannibal:latest - build: - context: . - args: - DOCKER_GID: "${DOCKER_GID:-999}" + image: registry.domandoman.xyz/cannibal:latest restart: unless-stopped environment: PRUNE_SCHEDULE: "0 3 * * *" # every day at 3am volumes: - /var/run/docker.sock:/var/run/docker.sock - group_add: - - "${DOCKER_GID:-999}" diff --git a/entrypoint.sh b/entrypoint.sh index 87fe4f5..f996b80 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,6 @@ echo "Docker pruner starting as $(whoami). Schedule: ${PRUNE_SCHEDULE}" # Write crontab from env var at runtime CRONTAB_FILE=/tmp/crontab -echo "${PRUNE_SCHEDULE} docker system prune -af >> /tmp/prune.log 2>&1" > "${CRONTAB_FILE}" +echo "${PRUNE_SCHEDULE} /bin/sh -c '/usr/bin/docker system prune -af >> /tmp/prune.log 2>&1'" > "${CRONTAB_FILE}" -exec supercronic "${CRONTAB_FILE}" +exec /usr/local/bin/supercronic "${CRONTAB_FILE}"