#!/usr/bin/env -S docker build . --tag=jcosmao/cron-git --network=host --file # docker push jcosmao/cron-git FROM alpine:latest ARG UNAME=user ARG UID=1000 ARG GID=1000 USER root RUN addgroup --system --gid ${GID} ${UNAME} RUN adduser --system --disabled-password --home /home/${UNAME} \ --uid ${UID} --ingroup ${UNAME} ${UNAME} RUN apk update \ && apk upgrade \ && apk --no-cache add dcron libcap RUN apk fix && \ apk --no-cache --update add git git-lfs gpg less openssh patch mandoc man-pages bash && \ git lfs install RUN chown $UID:$GID /usr/sbin/crond \ && setcap cap_setgid=ep /usr/sbin/crond COPY --chown=$UID:$GID entrypoint.sh /home/$UNAME/entrypoint.sh RUN chmod +x /home/$UNAME/entrypoint.sh USER $UNAME RUN mkdir /home/$UNAME/crontabs && touch /home/$UNAME/crontabs/$UNAME WORKDIR /home/$UNAME # install a cronjob: # echo SHELL=/bin/sh > ~/crontabs/user # echo '* * * * * my_cron' >> ~/crontabs/user # crond fail to setgid if run as PID 1 ENTRYPOINT ["./entrypoint.sh"]