Coder Social home page Coder Social logo

vladimirok5959 / docker-nginx-php-fpm Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

Docker base image with Nginx + PHP + FPM

License: MIT License

Dockerfile 46.13% Makefile 43.19% Shell 9.39% PHP 1.29%
nginx php fpm cgi docker php74 php74-fpm docker-image php-fpm php74-docker

docker-nginx-php-fpm's Introduction

docker-nginx-php-fpm

Docker base image with Nginx + PHP + FPM. PHP version 7.3. Pre-installed modules: gd, zip, curl, mysql, curl and mbstring. All env vars located here /var/www/.env. Document root directory here /var/www/html. All PHP settings defined by default except count of fpm forks, decreased to 1 and the same for Nginx server, worker_processes decreased to 1. Time zone can be binded at container startup from host machine by -v /etc/timezone:/etc/timezone:ro. Default server port is 80.

Docker image: https://hub.docker.com/r/vladimirok5959/nginx-php-fpm

Makefile

  • make docker-build - build docker image
  • make docker-export - export docker image to file
  • make docker-import - import docker image from file
  • make docker-test - run test container
  • make docker-push - push image to docker hub

Read ENVs from PHP

function LoadEnvironmentVariables() {
    $f = '../.env';
    if(file_exists($f)) {
        foreach(explode("\n", file_get_contents($f)) as $value) {
            if(trim($value) != '') {
                $pos = strpos($value, '=');
                if($pos === false) continue;
                $_ENV[substr($value, 0, $pos)] = substr($value, $pos + 1, strlen($value) - $pos - 1);
            }
        }
    }
}

// Example:
LoadEnvironmentVariables();
var_dump($_ENV);

Running docker container

docker run \
    --network host \
    --name my-container-name \
    -v /etc/timezone:/etc/timezone:ro \
    -v /path/to/php/files:/var/www/html \
    -d -it vladimirok5959/nginx-php-fpm:latest

Host network just for example, -v /etc/timezone:/etc/timezone:ro for getting time zone from host machine and -v /path/to/php/files:/var/www/html for rebind htdocs/www directory with PHP files, just for example if this image used as standalone without inheriting.

docker-nginx-php-fpm's People

Contributors

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