Sign inSign up

herliansyah/supercronic

By herliansyah

•Updated almost 2 years ago

A lightweight Docker image based on Alpine Linux for running cron jobs using Supercronic.

Image
Operating systems
0

766

herliansyah/supercronic repository overview

⁠Supercronic Alpine Docker Image

A lightweight Docker image based on Alpine Linux for running cron jobs using Supercronic v0.2.33. This image is optimized for running scheduled tasks in containerized environments with proper timezone support and logging capabilities.

⁠Change Log

  • 1.0 Alpine + curl + tzdata + supercronic ( can't use docker exec )
  • 1.1 Alpine + curl + tzdata + supercronic + docker ( can use docker exec but big image size)
  • 2.1 docker-in-docker + curl + tzdata + supercronic ( can use docker exec but still big image size)
  • 3.0 Alpine + curl + tzdata + supercronic + docker-cli ( can use docker exec with small image size)

⁠Features

  • Based on Alpine Linux for minimal footprint
  • Uses Supercronic v0.2.33 instead of traditional cron daemon
  • Pre-configured Asia/Jakarta timezone (configurable via TZ env)
  • Built-in curl for HTTP requests
  • Proper timezone handling with tzdata package
  • Simplified log management

⁠Technical Details

  • Base Image: alpine:latest
  • Supercronic Version: 0.2.33
  • Default Timezone: Asia/Jakarta
  • Included Packages:
    • curl
    • tzdata

⁠Quick Start

docker run -d \
  -v /path/to/crontab:/etc/cron.d/crontab:ro \
  -v /path/to/logs:/var/log \
  -e TZ=Asia/Jakarta \
  herliansyah/supercronic:3.0

⁠Environment Variables

  • TZ: Timezone (default: Asia/Jakarta)
  • SUPERCRONIC: Binary name (default: supercronic-linux-amd64)
  • SUPERCRONIC_URL: Binary download URL
  • SUPERCRONIC_SHA1SUM: SHA1 checksum for security verification

⁠Volumes

⁠Required
  • /etc/cron.d/crontab: Mount your crontab file (read-only recommended)
⁠Optional
  • /var/log: Directory for logs output

⁠Docker Compose Example

version: '3'
services:
  cron:
    image: herliansyah/supercronic:1.0
    environment:
      - TZ=Asia/Jakarta
    volumes:
      - ./crontab:/etc/cron.d/crontab:ro
      - ./logs:/var/log
      - /var/run/docker.sock:/var/run/docker.sock

⁠Crontab Example

# Format: minute hour day month weekday command
# Main cron log
*/5 * * * * echo "Task running" >> /var/log/cron.log 2>&1

# Task with curl example
0 * * * * curl -X POST http://api-endpoint >> /var/log/api-call.log 2>&1

# crontab with execute php in other docker container
*/1 * * * * docker exec php8.3-apache2.4 php /var/www/html/testauth.php >> /var/log/cron.log 2>&1

⁠Directory Structure

/
├── usr/local/bin/
│   ├── supercronic -> supercronic-linux-amd64
│   └── supercronic-linux-amd64
├── etc/
│   ├── cron.d/
│   │   └── crontab
│   ├── timezone
│   └── localtime
└── var/
    └── log/

⁠Security Features

  • SHA1 checksum verification for Supercronic binary
  • Read-only crontab mounting recommended
  • Based on official Alpine image

⁠Build Information

FROM alpine:latest

ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \
    SUPERCRONIC_SHA1SUM=71b0d58cc53f6bd72cf2f293e09e294b79c666d8 \
    SUPERCRONIC=supercronic-linux-amd64 \
    TZ=Asia/Jakarta

RUN apk add --no-cache curl
RUN apk add --no-cache docker-cli
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

RUN apk add --no-cache tzdata \
    && cp /usr/share/zoneinfo/$TZ /etc/localtime \
    && echo $TZ > /etc/timezone

RUN mkdir -p /etc/cron.d

CMD ["/usr/local/bin/supercronic", "/etc/cron.d/crontab"]

⁠Supported Tags

  • 3.0: Current stable version
  • latest: Latest build

⁠Credits

⁠License

MIT

⁠Notes

  • The image verifies Supercronic binary integrity using SHA1
  • Timezone data is properly configured using tzdata package
  • Logs are not automatically rotated - consider implementing log rotation
  • Supercronic provides better logging and process management than traditional cron

Tag summary

Content type

Image

Digest

sha256:a178725fa…

Size

22.3 MB

Last updated

almost 2 years ago

docker pull herliansyah/supercronic:3.0