Giter VIP home page Giter VIP logo

docker-php's Introduction

PHP application server

This image provides ready to go application server based on Alpine, Nginx and PHP-FPM. Container main process is runit process. Also in the image we have some preinstalled apps: composer, git, openssh, runit, bash and self-signed keys for Nginx.

Usage

To run this docker-compose below you should create .env file and create APP_HTTP_PORT and APP_HTTPS_PORT variables.

version: '3.7'

services:
    app:
        image: mgdteam/php:8.2-fpm-nginx
        ports:
            - 127.0.0.1:${APP_HTTP_PORT}:80
            - 127.0.0.1:${APP_HTTPS_PORT}:443
        volumes:
            - ./app:/var/www/app:cached
        
    queue-worker:
        image: mgdteam/php:8.2-cli
        volumes:
            - ./app:/var/www/app:cached
        # Command can be run in container periodically
        # Command format: /entrypoint.cmd.sh <command> <run-interval-in-seconds>
        # Example: command: bin/console messenger:consume async -vv

Customize PHP and Nginx configuration

To configure PHP and Nginx you should create new Dockerfile and override config files to your own. Dockerfile example:

FROM mgdteam/php:8.2-fpm-nginx

# Change php configuration
ADD ./php/php.ini "$PHP_INI_DIR/conf.d/my-custom.ini"

# Change nginx configuration
ADD ./nginx/nginx.conf /etc/nginx/nginx.conf

# Change nginx vhosts configuration
ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf

Run additional services inside the container

The PHP-FPM container has runit on board. To run a user service with runit need to create a run script and copy it according to the example below. Example of a run script (e.g. ./php/runit/messenger-worker/run) to start a user service (e.g. Symfony messenger consumer):

#!/usr/bin/env sh
php /var/www/app/bin/console messenger:consume async

Copy this script during Dockerfile building to the predefined runit services folder:

RUN mkdir -p "/run/messenger-worker"
RUN mkdir -p "$SERVICE_AVAILABLE_DIR/messenger-worker*"
COPY ./php/runit/messenger-worker/run "$SERVICE_AVAILABLE_DIR/messenger-worker/run"
RUN chmod +x "$SERVICE_AVAILABLE_DIR/messenger-worker/run"
RUN ln -s "$SERVICE_AVAILABLE_DIR/messenger-worker" ${SERVICE_ENABLED_DIR}

So the run script will be demonized and started in a separate process during container running.

docker-php's People

Contributors

archer-developer avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.