Sign inSign up

devitools/hyperf

By devitools

β€’Updated about 1 year ago

Optimized image for running Hyperf applications with PostgreSQL and Swoole support.

Image
0

2.6K

devitools/hyperf repository overview

⁠Devitools Hyperf

Optimized image for running Hyperf applications with PostgreSQL and Swoole support.

⁠Introduction

This Docker image is designed to provide an optimized environment for Hyperf applications running PHP 8.3, supporting both development and production environments.

It includes specific configurations for Xdebug, Sonar Scanner, PHP performance tuning, and static code analysis support.

β πŸ› οΈ How to Use

⁠Run a Container Directly
docker run --rm --name hyperf -d -v "$(pwd):/opt/www" -p "8080:9501" --platform linux/amd64 devitools/hyperf:8.3-dev
⁠Example Dockerfile Ready for Production
FROM devitools/hyperf:8.3

COPY . /opt/www

RUN composer install --prefer-dist --no-dev --optimize-autoloader

β πŸš€ Example docker-compose.yml Ready for dev

services:
  app:
    image: devitools/hyperf:8.3-dev
    container_name: template_name-app
    command: [ "server:watch" ]
    volumes:
      - ./:/opt/www
    ports:
      - "9501:9501"
    environment:
      - SCAN_CACHEABLE=false
      - STDOUT_LOG_LEVEL=alert,critical,emergency,error,warning,notice,info
    restart: on-failure

β πŸ“Œ Environment Variables

  • SCAN_CACHEABLE: Controls Hyperf’s scan cache.
  • STDOUT_LOG_LEVEL: Sets the log levels sent to stdout.

β πŸ—οΈ Just Run, no Build

docker-compose up -d

β πŸ“¦ Image Contents

The image includes:

  • PHP 8.3 with essential extensions
  • Composer for dependency management
  • Xdebug and PCOV for debugging and code coverage
  • Sonar Scanner for code quality analysis
  • Adjustable timezone configuration
  • Support for static code analysis via SonarQube

β πŸ› οΈ Configuration and Installation

The image configuration is handled through the following scripts:

⁠setup.sh
  • Adjusts PHP settings, including memory limit, upload_max_filesize, and timezone.
  • Configures the system timezone.
⁠setup-dev.sh
  • Installs development dependencies, including Xdebug and Sonar Scanner.
  • Configures xdebug.ini for PHPStorm integration.
  • Disables embedded JRE in Sonar Scanner to avoid conflicts.

β πŸ“Œ How to Build the Image

The image can be built in two ways: for development and for production.

β πŸ”Ή Development Image

Includes Xdebug, PCOV, and Sonar Scanner for debugging and code analysis.

docker build --platform="linux/amd64" --build-arg APP_TARGET=dev -t devitools/hyperf:8.3-dev .
β πŸ”Ή Production Image

Removes development tools to optimize the runtime environment.

docker build --platform="linux/amd64" -t devitools/hyperf:8.3 .

β πŸš€ Differences Between Versions

VersionIncluded Features
devitools/hyperf:8.3-devPHP 8.3 + Xdebug + PCOV + Sonar Scanner
devitools/hyperf:8.3PHP 8.3 optimized for production

β πŸ›  Usage

To run a container based on the image:

docker run --rm -it devitools/hyperf:8.3-dev php -v

To start a Hyperf project with the image:

docker run --rm -it -v $(pwd):/opt/www devitools/hyperf:8.3-dev composer create-project hyperf/hyperf-skeleton .

β πŸ“Œ Conclusion

This image provides a complete environment for developing and running Hyperf applications, ensuring productivity and code quality.

Tag summary

Content type

Image

Digest

sha256:6fe081035…

Size

36 MB

Last updated

over 1 year ago

docker pull devitools/hyperf