Sign inSign up

jthegunner/php-composer-npm-amd

By jthegunner

•Updated 10 months ago

Docker image which provides everything to deploy PHP Applications. Includes PHP, Composer, npm

Image
Web servers
0

2.2K

jthegunner/php-composer-npm-amd repository overview

⁠Docker Image: PHP 8.3 FPM & Tooling

⁠Overview

This Docker image provides a fully featured development and runtime environment based on PHP 8.3.14-fpm. It is optimized for modern PHP applications, integrating necessary extensions, Composer, Node.js assets, and Quality Assurance tools.

It leverages mlocati/php-extension-installer for efficient extension management and combines system dependency installation to minimize image size.

⁠Technical Stack

ComponentVersionDescription
OS / BaseDebian (via PHP image)Official php:8.3.14-fpm base.
PHP8.3.14FastCGI Process Manager (FPM).
ComposerLatestCopied from official composer:latest.
Node.jsRepository VersionInstalled via apt.
Package Managersnpm, yarnYarn installed globally via npm.
Process ManagerPM2Node process manager installed globally.

⁠PHP Extensions

The following extensions are installed and configured:

  • System/Core: bcmath, intl, pcntl, opcache, zip
  • Database: pdo_mysql
  • Image Processing: gd
  • Debugging: xdebug (Configured via .docker/xdebug.ini)

⁠Installed Tools & Utilities

⁠System Utilities
  • git - Version control
  • wget - Network downloader
  • zip / unzip - Archive handling
⁠Quality Assurance (QA)

The following PHAR archives are installed to /usr/local/bin/:

  1. phpcpd (PHP Copy/Paste Detector) - Detects duplicated code.
  2. phpmd (PHP Mess Detector) - Analyzes source code for potential problems.

⁠Configuration Details

  • Working Directory: /var/www/html
  • Exposed Port: 9000 (Standard PHP-FPM)
  • Composer Home: /composer

⁠Usage Example (Docker Compose)

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./:/var/www/html
    ports:
      - "9000:9000"
    environment:
      - PHP_IDE_CONFIG=serverName=localhost

⁠Usage Example (Kubernetes Deployment)

This example demonstrates how to deploy this image in a Kubernetes environment (like k3s). It includes a Deployment for the pods and a Service to expose port 9000 internally.

Note: As this is a PHP-FPM container, it communicates via the FastCGI protocol. You will typically need an Nginx sidecar or an Ingress Controller that supports FastCGI (like Traefik or Nginx Ingress) to serve traffic to it.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: php-fpm-deployment
  labels:
    app: PhpFpmApp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: PhpFpmApp
  template:
    metadata:
      labels:
        app: PhpFpmApp
    spec:
      containers:
        - name: php-fpm-container
          image: your-registry/php-fpm-image:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 9000
              name: fastcgi
          # Resource limits are recommended for production
          resources:
            requests:
              memory: "128Mi"
              cpu: "100m"
            limits:
              memory: "512Mi"
              cpu: "500m"
          # Basic TCP check (since FPM does not speak HTTP natively)
          livenessProbe:
            tcpSocket:
              port: 9000
            initialDelaySeconds: 5
            periodSeconds: 10
          readinessProbe:
            tcpSocket:
              port: 9000
            initialDelaySeconds: 5
            periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: php-fpm-service
spec:
  selector:
    app: PhpFpmApp
  ports:
    - protocol: TCP
      port: 9000
      targetPort: 9000
  type: ClusterIP

Tag summary

Content type

Image

Digest

sha256:b95c5c888…

Size

71.6 MB

Last updated

10 months ago

docker pull jthegunner/php-composer-npm-amd