well, fixed some problems with path etc but works now

This commit is contained in:
Piotr Domański 2026-04-03 21:18:05 +02:00
parent 256e9b9fc6
commit e93831009c
4 changed files with 7 additions and 12 deletions

View file

@ -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

View file

@ -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 \
.

View file

@ -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}"

View file

@ -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}"