aptible / supercronic

Cron for containers
MIT License
1.91k stars 115 forks source link

Level-based logging by default on Docker alpine image #91

Closed quentinbustarret closed 3 years ago

quentinbustarret commented 3 years ago

Hello,

First and foremost, thanks a lot for the super useful piece of software.

I am running a node script hourly on a alpine based Docker image and logs are by default logged as level-based, which I find too verbose and uneasy to read. In addition, logs are not dated from my Time Zone, which I suspect is caused by the same issue. I tried using TZ and CRON_TZ env variables, without success.

Here is my Dockerfile :

FROM node:16.5.0-alpine3.14

RUN apk --no-cache add dumb-init
ENV NODE_ENV production

# Adding support for cron
RUN apk --no-cache add curl
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
    SUPERCRONIC=supercronic-linux-amd64 \
    SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e
RUN curl -fsSLO "$SUPERCRONIC_URL" \
 && echo "${SUPERCRONIC_SHA1SUM}  ${SUPERCRONIC}" | sha1sum -c - \
 && chmod +x "$SUPERCRONIC" \
 && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
 && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

USER node
WORKDIR /usr/src/app
COPY --chown=node:node package*.json ./
RUN npm ci --only=production

COPY --chown=node:node . /usr/src/app

ENTRYPOINT ["dumb-init"]
CMD ["supercronic", "./config/crontab"]

And my crontab : 0 */1 * * * TZ="Europe/Paris" node index.js Here are my logs :

Capture d’écran 2021-07-28 à 11 36 13

Thanks you for your help !

quentinbustarret commented 3 years ago

Found a fix with adding -t flag when running my Docker image.