Skip to content

Latest commit

 

History

History
126 lines (91 loc) · 2.77 KB

docker.md

File metadata and controls

126 lines (91 loc) · 2.77 KB

Documentation: OSIRIS PHP Docker Image

Overview

This Dockerfile creates an optimized PHP-FPM image for the OSIRIS application. It uses a multi-stage build process to minimize the resulting image size and improve build efficiency.

Technical Details

  • Base Image: PHP 8.1 with FPM on Alpine Linux
  • PHP Extensions:
    • LDAP
    • ZIP
    • MongoDB
  • Author: Paul C. Gaida

Build Process

The Dockerfile implements a two-stage build process:

  1. Composer Stage:

    • Installs Composer and PHP dependencies
    • Uses only the necessary files (composer.json and composer.lock)
    • Optimized for better caching and faster builds
  2. Main Stage:

    • Installs necessary system packages and PHP extensions
    • Copies the vendor files installed in the first stage
    • Copies the application code and sets up permissions

Installed Packages and Extensions

  • System Packages:

    • openldap-dev (for LDAP support)
    • libzip-dev (for ZIP support)
    • openssl-dev (for secure connections)
    • autoconf, gcc, g++, make (build tools for extension compilation)
  • PHP Extensions:

    • ldap (for LDAP authentication)
    • zip (for ZIP file handling)
    • mongodb (for MongoDB database connections)

Usage

Prerequisites

  • Docker installed on the host system
  • The OSIRIS source files in the current directory

Building the Image

docker build -t osiris:latest .

Starting a Container

docker run -d --name osiris-app -p 9000:9000 osiris:latest

To use the application with a web server, connect it to the PHP-FPM port 9000.

With Volumes for Development

docker run -d --name osiris-app \
  -p 9000:9000 \
  -v $(pwd):/var/www/html \
  osiris:latest

With Docker Compose

Create a docker-compose.yml file:

version: '3'

services:
  app:
    build:
      context: nginx
      dockerfile: nginx/Dockerfile
    volumes:
      - ./img:/var/www/html/img
    ports:
      - "9000:9000"

  web:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./:/var/www/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app

And start the services:

docker-compose up -d

Notes

  • The image is optimized for production and contains no development tools
  • The /var/www/html/img directory has extended write permissions for the www-data user
  • Vendor dependencies are installed during the build and placed in the final image
  • Only the PHP extensions necessary for the application are installed

Customizations

To install additional PHP extensions, extend the docker-php-ext-install command:

RUN docker-php-ext-install ldap zip mysqli pdo_mysql

To install additional PECL extensions:

RUN pecl install redis && docker-php-ext-enable redis