Git Product home page Git Product logo

docker-nginx-php-fpm's Introduction

What could go wrong?

This image aims to simplify building and deploying PHP web applications with a single container you can throw behind traefik or nginx-proxy.

This project is a work in progress and a place to test different ways of running nginx + php-fpm in the same container.

Please note: This image is effectively unstable and likely to have breaking changes for the forseeable future. I suggest using it as a starting point for your own needs.

Why would you do this?

Nginx + PHP-FPM as a single image vs separate images has always been hotly debated. While keeping them separate is standard practice: it has downsides without many upsides weighing in.

This project serves to explore what happens when you treat Nginx + PHP-FPM as a single application and focus on containerization of your code - the thing that really matters.

How does it work?

This image runs supervisord in the foreground which in turn runs nginx/php-fpm in the background. Both nginx/php-fpm are configured to log to stdout/stderr which can then picked up by docker logging as you would expect.

Example standalone usage (available at http://localhost/)

docker run --rm -it -p80:80 -v ~/www:/www lslio/nginx-php-fpm

Example usage with volume map and server name change (available at http://example.localhost/)

docker run --rm -it -v ~/www:/www -p 80:80 -e SERVER_NAME=example.localhost lslio/nginx-php-fpm

Example Dockerfile usage

FROM lslio/nginx-php-fpm

ENV SERVER_NAME=example.com
ENV SERVER_ALIAS=www.example.com
ENV SERVER_ROOT=/www

COPY . /www
version: '3.6'

services:
  example:
    image: lslio/nginx-php-fpm
    volumes:
      - .:/www
    ports:
      - "80:80"
    environment:
      SERVER_NAME: "example.localhost"

Example docker-compose.yml for Multiple Laravel installs behind nginx-proxy

version: '3.6'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  example-web:
    image: lslio/nginx-php-fpm
    volumes:
      - ./web:/www
    environment:
      VIRTUAL_HOST: "example.localhost"
      SERVER_ROOT: "/www/public"

  example-api:
    image: lslio/nginx-php-fpm
    volumes:
      - ./api:/www
    environment:
      VIRTUAL_HOST: "api.example.localhost"
      SERVER_ROOT: "/www/public"

Props

docker-nginx-php-fpm's People

Contributors

lsl 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.