Sign inSign up

infraunnes/php-cli

By infraunnes

•Updated 4 months ago

PHP stack with Supercronic (Cron for Containers)

Image
Web servers
0

9.2K

infraunnes/php-cli repository overview

⁠Docker Hub Repository Overview: infraunnes/php-cli:alpine

Repository Name: infraunnes/php-cli:alpine

Description:

This Docker image provides a lightweight Alpine Linux environment with PHP, Composer, and Supercronic for running PHP CLI applications and scheduled tasks. It includes essential PHP extensions and tools for development and deployment.

Key Features:

  • Alpine Linux Base: Minimal image size for efficient resource utilization.
  • PHP: Uses the latest PHP available in the alpine edge repository.
  • Essential PHP Extensions: Includes common extensions like curl, gd, mysqli, mbstring, zip, xml, and json.
  • Development Tools: Contains tools like git, curl, wget, make, rsync, nano, and mysql-client.
  • Composer: Pre-installed Composer for dependency management.
  • Supercronic: A lightweight, cron-like process manager for running scheduled tasks within the container.
  • Tini: Process supervisor for proper signal handling.
  • Multi-Platform Support: Built with docker buildx for multi-architecture compatibility (amd64, arm64).

Supercronic:

Supercronic is a simple, reliable cron replacement designed for running scheduled tasks inside Docker containers. It reads cron schedules from a specified file (default: /root/crontab.txt) and executes the corresponding commands. This allows you to easily manage cron jobs within your containerized applications.

Usage:

  1. Pull the Image:

    docker pull infraunnes/php-cli:8.4-alpine
    
  2. Create a crontab.txt File:

    Create a file named crontab.txt in the same directory as your Dockerfile or docker-compose.yml. This file should contain your cron schedules in standard cron format. For example:

    * * * * * php /var/www/your-script.php
    
  3. Run a Container:

    docker run -d -v /path/to/your/crontab.txt:/root/crontab.txt infraunnes/php-cli:8.4alpine
    
    • Replace /path/to/your/crontab.txt with the local path to your crontab.txt file.
  4. Mount your application:

    docker run -d -v /path/to/your/crontab.txt:/root/crontab.txt -v /path/to/your/app:/var/www infraunnes/php-cli:8.4-alpine
    
    • Replace /path/to/your/app with the local path to your PHP application.

Dockerfile Breakdown:

  • Base Image: alpine:edge provides a minimal Alpine Linux environment.
  • Dependencies: Installs essential PHP packages, extensions, and development tools using apk.
  • Composer Installation: Downloads and installs Composer using curl and php.
  • Supercronic Installation: Downloads and installs Supercronic based on the architecture.
  • rootfs: Copies the application code from the rootfs directory into the container's root directory.
  • ENTRYPOINT: Sets tini as the entry point, starting Supercronic with the specified crontab.txt file.
  • CMD: Not used, the entrypoint overrides the command.

Customization:

  • To install additional PHP extensions, add apk add php-<extension-name> to the Dockerfile.
  • To modify the Supercronic version, change the SUPERCRONIC_VERSION argument.
  • To change the location of the crontab.txt file, modify the ENTRYPOINT command.

Note:

  • This image is designed for running PHP CLI applications and scheduled tasks.
  • Ensure your crontab.txt file has the correct file permissions.

Tag summary

Content type

Image

Digest

sha256:c40b49c64…

Size

85.4 MB

Last updated

4 months ago

docker pull infraunnes/php-cli:8.5-alpine