Skip to content

Docker Deployment ​

Because Nexphant functions as a standalone managed runtime, deploying it inside Docker is exceptionally simple. There is no need to configure Nginx, PHP-FPM, supervisord, or socket paths. Nexphant acts as its own web server and scheduler.

Minimal Dockerfile ​

Here is a production-optimized Dockerfile for a Nexphant application. It uses a clean CLI image and installs the necessary extensions.

dockerfile
# Production-ready CLI base image
FROM php:8.2-cli-alpine

# Install system dependencies and PHP extensions
RUN apk add --no-cache \
        libpng-dev \
        libjpeg-turbo-dev \
        freetype-dev \
        bash \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd pcntl posix pdo pdo_mysql

# Set working directory
WORKDIR /var/www/html

# Copy application files
COPY . .

# Install dependencies (if not done in CI)
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN composer install --no-dev --optimize-autoloader --no-interaction

# Expose HTTP port
EXPOSE 8080

# Run Nexphant application
CMD ["php", "app.php"]

Docker Compose Configuration ​

To deploy your application with database and cache systems, you can use the following docker-compose.yml config:

yaml
version: '3.8'

services:
  app:
    build: .
    ports:
      - "8080:8080"
    environment:
      - APP_ENV=production
      - DB_HOST=db
      - DB_DATABASE=nexphant_db
      - DB_USERNAME=root
      - DB_PASSWORD=secret
    depends_on:
      - db

  db:
    image: mysql:8.0
    environment:
      - MYSQL_DATABASE=nexphant_db
      - MYSQL_ROOT_PASSWORD=secret
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:

Graceful Termination in Containers ​

When orchestrators like Kubernetes or Docker Swarm scale down or deploy new instances, they send a SIGTERM signal to the container's PID 1 process.

Nexphant catches SIGTERM and initiates a Graceful Drain:

  1. Stops accepting incoming TCP connections on port 8080.
  2. Completes all in-flight HTTP requests and active queue jobs.
  3. Closes persistent database connection pools safely.
  4. Exits with code 0.

IMPORTANT

Make sure your Dockerfile executes PHP directly (e.g. CMD ["php", "app.php"]) rather than wrapping it in a shell script without exec. Wrapping it without exec will block the signals from reaching Nexphant.

Released under the MIT License.