Git Product home page Git Product logo

php-pm-docker's Introduction

PHP-PM Docker

You can use PHP-PM using Docker. We provide you several images always with PHP-PM and PHP7 pre-installed.

Images

  • phppm/nginx: Contains php-pm and uses NGiNX as static file serving
  • phppm/standalone: Contains php-pm and uses php-pm's ability to serve static files (slower)
  • phppm/ppm: Just the php-pm binary as entry point

Examples

# change into your project folder first
cd your/symfony-project/

# see what php-pm binary can do for you.
$ docker run -v `pwd`:/var/www/ phppm/ppm --help
$ docker run -v `pwd`:/var/www/ phppm/ppm config --help

# with nginx as static file server
$ docker run -v `pwd`:/var/www -p 8080:80 phppm/nginx

# with php-pm as static file server (dev only)
$ docker run -v `pwd`:/var/www -p 8080:80 phppm/standalone

# use `PPM_CONFIG` environment variable to choose a different ppm config file.
$ docker run  -v `pwd`:/var/www -p 80:80 phppm/nginx -c ppm-prod.json

# enable file tracking, to automatically restart ppm when php source changed
$ docker run -v `pwd`:/var/www -p 80:80 phppm/nginx --debug=1 --app-env=dev

# change static file directory. PPM_STATIC relative to mounted /var/www/.
$ docker run -v `pwd`:/var/www -p 80:80 phppm/nginx --static-directory=web/

# Use 16 threads/workers for PHP-PM.
$ docker run -v `pwd`:/var/www -p 80:80 phppm/nginx --workers=16

Docker compose

version: "3.1"

services:
  ppm:
    image: phppm/nginx
    command: --debug=1 --app-env=dev --static-directory=web/
    volumes:
      - ./symfony-app/:/var/www
    ports:
      - "80:80"

Configuration

You should configure PPM via the ppm.json in the root directory, which is within the container mounted to /var/www/. Alternatively, you can overwrite each option using the regular cli arguments.

# change the ppm.json within current directory
docker run -v `pwd`:/var/www phppm/ppm config --help

# not persisting config changes
docker run -v `pwd`:/var/www -p 80:80 phppm/nginx --help
docker run -v `pwd`:/var/www -p 80:80 phppm/nginx --workers=1 --debug 1
docker run -v `pwd`:/var/www -p 80:80 phppm/nginx --c prod-ppm.json

Build image with own tools/dependencies

If your applications requires additional php modules or other tools and libraries in your container, you can use our image as base. We use lightweight Alpine Linux.

# Dockerfile
FROM phppm/nginx:1.0

RUN apk --no-cache add git
RUN apk --no-cache add ca-certificates wget

# whatever you need 
docker build vendor/my-image -f Dockerfile .
# now use vendor/my-image instead of `phppm/nginx`

php-pm-docker's People

Contributors

andig avatar antontyutin avatar cordoval avatar machy8 avatar marcj avatar ssipos90 avatar wanghanlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-pm-docker's Issues

Composer command in Dockerfile fails due to inconsistent version requirements

The following composer commands fail when the image is built:

composer require php-pm/php-pm:${version} && composer require php-pm/httpkernel-adapter:${http_version}

By default, php-pm/php-pm:${version} requires the master branch. However, httpkernel-adapter requires php-pm/php-pm: "^1.0". This creates a conflict as both versions can't be co-installed.

The 'simple' solution may be to just remove the composer call to install php-pm/php-pm and just let it pull it in as the php-pm/httpkernel-adapter dependency.

How to make Xdebug work with docker

When xdebug is configured and my IDE is listening on upcoming connections the problem occurs because a /tmp/dbgKbNLhm (where new ProcessSlave is created) is not mapped to any path on my host. I could bind a dedicated volume but still my IDE (PHPStorm) does not allow to map paths outside a project.

update alpine

Can we update safely to alpine 3.7 instead of current 3.6?
alpine 3.7 ship nodejs v8 in apk, but its v6 in 3.6, it can easy some work.
if it's ok, i can submit a PR

nginx docker - php files are downloaded not executed.

Visiting a .php url results in downloading the file instead of running it.

How to reproduce:

#installed symfony cli tool:
sudo mkdir -p /usr/local/bin
sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

#create a new symfony 3.4 project:
symfony new blog 3.4
cd blog
composer install --prefer-dist

#run ppm-nginx docker
docker run -v `pwd`:/var/www -p 8080:80 phppm/nginx

#visit .php file:
http://localhost:8080/web/app.php

This results in downloading the .php file and not running the code.

At least we should block downloading of .php and other relevant types. Ideally we should be able to run them.

Thanks

No response from server

Built skeleton laravel app with:
docker run --rm -it -v /$PWD:/app composer:1.6.1 create-project --prefer-dist laravel/laravel demo3

$ docker pull phppm/nginx
Using default tag: latest
latest: Pulling from phppm/nginx
Digest: sha256:1b96765ad7b0f5cf43e47c41eab4aad26c8d1215c200f1d2fed81a1c7fde5df9
Status: Image is up to date for phppm/nginx:latest

Running with:

$ docker run --rm --name ppm -v /$PWD:/var/www -p 29080:8080 phppm/nginx:latest --debug=1 --app-env=dev --static-directory=web --bootstrap=laravel
/var/www
+---------------------+-------------------+
| bridge              | HttpKernel        |
| host                | 127.0.0.1         |
| port                | 8080              |
| workers             | 8                 |
| app-env             | dev               |
| debug               | 1                 |
| logging             | 1                 |
| static-directory    | web               |
| bootstrap           | laravel           |
| max-requests        | 1000              |
| populate-server-var | 1                 |
| socket-path         | /ppm/run          |
| pidfile             | /ppm/ppm.pid      |
| cgi-path            | /usr/bin/php-cgi7 |
+---------------------+-------------------+
Starting PHP-PM with 8 workers, using StreamSelectLoop ...
8 workers (starting at 5501) up and ready. Application is ready at http://127.0.0.1:8080/

And no response on port 29080

Inside docker container

/var/www # ls -l
total 166
drwxr-xr-x    2 root     root             0 Jan 12 11:42 app
-rwxr-xr-x    1 root     root          1686 Jan 12 11:42 artisan
drwxr-xr-x    2 root     root             0 Jan 12 11:42 bootstrap
-rwxr-xr-x    1 root     root          1413 Jan 12 11:42 composer.json
-rwxr-xr-x    1 root     root        143452 Jan 12 11:46 composer.lock
drwxr-xr-x    2 root     root             0 Jan 12 11:42 config
drwxr-xr-x    2 root     root             0 Jan 12 11:42 database
-rwxr-xr-x    1 root     root          1125 Jan 12 11:42 package.json
-rwxr-xr-x    1 root     root          1040 Jan 12 11:42 phpunit.xml
drwxr-xr-x    2 root     root             0 Jan 12 11:42 public
-rwxr-xr-x    1 root     root          3550 Jan 12 11:42 readme.md
drwxr-xr-x    2 root     root             0 Jan 12 11:42 resources
drwxr-xr-x    2 root     root             0 Jan 12 11:42 routes
-rwxr-xr-x    1 root     root           563 Jan 12 11:42 server.php
drwxr-xr-x    2 root     root             0 Jan 12 11:42 storage
drwxr-xr-x    2 root     root             0 Jan 12 11:42 tests
drwxr-xr-x    2 root     root             0 Jan 12 11:46 vendor
-rwxr-xr-x    1 root     root           549 Jan 12 11:42 webpack.mix.js
/var/www # ps aux
PID   USER     TIME   COMMAND
    1 root       0:00 /bin/bash /etc/app/run.sh --debug=1 --app-env=dev --static-directory=web --bootstrap=laravel
   20 root       0:00 nginx: master process nginx
   22 nginx      0:00 nginx: worker process
   23 nginx      0:00 nginx: worker process
   24 nginx      0:00 nginx: worker process
   25 nginx      0:00 nginx: worker process
   27 root       0:00 php /ppm/vendor/bin/ppm start --ansi --port=8080 --socket-path=/ppm/run --pidfile=/ppm/ppm.pid --static-directory='' --debug=1 --app-env=dev --static-directory=web --bootstrap=laravel
   38 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbghKGNEA
   39 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbglknBIN
   40 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbglejjMf
   41 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbgdIlGLk
   42 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbgHHlHhl
   43 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbgHmiAHl
   44 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbgpcJjBg
   45 root       0:00 /usr/bin/php-cgi7 -C /tmp/dbgPkCAaI
   46 root       0:00 sh
   53 root       0:00 ps aux

Build image from phppm/nginx

I don't have a lot of experience with Docker & images, but dont know where to look about this problem.

I'm trying to create a custom image starting from phppm/nginx, and then use that image from docker-compose. But when specifing the "command" (debug and static-directory options) is not using them.

# Dockerfile in phpdocker/php-ppm/Dockerfile
FROM phppm/nginx

RUN apk --no-cache add git
RUN apk --no-cache add ca-certificates wget php7-iconv php7-ftp \
    && rm -rf /var/lib/apk/*

# whatever you need
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

After building the image with: docker build phpdocker/php-ppm -t publisher/ppm-ws

Using the previous image within docker-compose: (pay attention to "image")

version: "3.0"
services:
    ppm:
      image: publisher/ppm-ws:latest
      command: --debug=1 --app-env=dev --static-directory=web/
      volumes:
        - ./:/var/www
      ports:
        - "1080:80"

Now executing docker-compose up ppm shows this:

ppm_1        | /var/www
ppm_1        | +---------------------+--------------------------+
ppm_1        | | bridge              | HttpKernel               |
ppm_1        | | host                | 127.0.0.1                |
ppm_1        | | port                | 8080                     |
ppm_1        | | workers             | 8                        |
ppm_1        | | app-env             | dev                      |
ppm_1        | | debug               | 0                        |
ppm_1        | | logging             | 1                        |
ppm_1        | | static-directory    | ""                       |
ppm_1        | | bootstrap           | PHPPM\Bootstraps\Symfony |
ppm_1        | | max-requests        | 1000                     |
ppm_1        | | populate-server-var | 1                        |
ppm_1        | | socket-path         | .ppm/run/                |
ppm_1        | | pidfile             | .ppm/ppm.pid             |
ppm_1        | | cgi-path            | /usr/bin/php-cgi7        |
ppm_1        | +---------------------+--------------------------+
ppm_1        | Starting PHP-PM with 8 workers, using StreamSelectLoop ...

Why is not using "static-directory" and "debug"?
Or better yet, how could I change this? Also tried with "environment" within docker-compose without success :(

Thank you guys for this!

Setup automatic docker build on new release

Everytime we tag a new release, we should build the docker image automatically. Dunno how at the moment. Maybe we can use Github's API and detect when a new tag has been added and then kickstart some build on a buildsystem.

Allow listening on port 8080 so PHPPM can be used in Google App Engine

I'm working on building a project to be hosted in Google App Engine with a custom runtime (ie., docker container) based on phppm/docker. However, GAE requires that custom runtimes listen on port 8080:

From the GAE documentation:

Listen to port 8080
The App Engine front end will route incoming requests to the appropriate module on port 8080. You must be sure that your application code is listening on 8080.

It would be nice if the ultimate end port the docker images listened on was configurable from the Dockerfile in our custom container. Perhaps something like this:

FROM phppm/nginx
ENV PPM_LISTEN_ON 8080
COPY web/ /var/www

and then have the PHPPM docker container we are extending automatically configure itself to listen on that port we've set.

Supported PHP version, automated builds, better tags?

It is more a question than an issue. Containers on dockerhub looks a bit outdated - maybe it is a good idea to make some automated builds on webhooks? Also supporting more specified tags (with php version - I've tried with updating php version to 7.2 but it is quite complicated) would be nice - many projects require 7.2 php version due to object typehinting.

I may help, but don't want to make something which won't be accepted later :)

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.