lorisleiva / laravel-docker

🐳 Generic docker image for Laravel Applications
MIT License
934 stars 314 forks source link

[Vote] FPM support #33

Open polarathene opened 5 years ago

polarathene commented 5 years ago

Is there a reason for opting for php:alpine over php:fpm-alpine or not offering the fpm variant as well?

It doesn't seem straight-forward to extend this image to add that fpm support looking at the Dockerfile for fpm variant(there's additional args run from an env var during the build).

Forking this repo just to replace the base image with the variant should work, but that doesn't seem like the right way to go about it.

lorisleiva commented 5 years ago

Hi there 👋

To be honest, I originally created this image for continuous integration tools so I never really needed FPM but I'm willing to consider using it as a new set of images.

My primary goal for this image is to stay as small as possible whilst covering the 80% use cases of Laravel users. FPM being a pretty important part of PHP, I think you make a good point.

Could I ask you why you need FPM in your case? Are you using this image in a production server?

@fgilio Franco, do you have any strong opinion on this?

polarathene commented 5 years ago

Are you using this image in a production server?

Just recently added it to a server due to a request from a PHP dev for a Laravel setup, it's not serving a production site or service at present. Other PHP based containers I have been using are all this trafex/alpine-nginx-php7 image, which also bundled nginx as their webservers, which are used in combination with nginx-proxy.

In future, I plan to migrate the reverse-proxy to Traefik, and not being too familiar with PHP environments myself(this is a non-profit community rather than commercial). I've only recently been aware that nginx can be separated out to it's own container while using the fpm related part of nginx config.

When I set these PHP containers up for their community a couple years back, I recall FPM being important / helpful improvement, it has about 1,000 active users, not that big, but not too small either. Most guides for using nginx with PHP mention with FPM afaik, so it may have been related to that as well.

Presently the container is setup like so with docker-compose(I know that artisan is not meant to be used for production, and will switch it when I've had time to figure out how):

  laravel:
    image: lorisleiva/laravel-docker:7.3
    container_name: test_laravel
    restart: always
    ports:
      - 8000:8000
    links:
      - db
    environment:
      VIRTUAL_PORT: 8000
      VIRTUAL_HOST: laravel.example.tld
      LETSENCRYPT_HOST: laravel.example.tld
      LETSENCRYPT_EMAIL: ${ADMIN_EMAIL}
    volumes:
      - ./websites/laravel/hello_world:/var/www/laravel
    working_dir: /var/www/laravel/
    command: php artisan serve --port=8000 --host=0.0.0.0

The host param for artisan needed to be 0.0.0.0(listen on all interfaces, not just loopback/localhost of the container), otherwise the docker host would get connection failures when making a request to the container despite the port mapping.

The working_dir, was because of the default one has an "html" directory and I'm mounting the laravel project(I could have gone with anything else like /srv/laravel too I guess). I'm not sure if the "html" dir mattered or not when mounting a volume, but wanted to avoid dealing with any potential surprises later.

I originally created this image for continuous integration tools

There doesn't appear to be any official Laravel images on DockerHub and yours seemed to be a reasonably popular and still maintained image, after evaluating several others out there I decided yours was most appropriate for getting something up and going with minimal fuss.

Your CI with GitLab Pipelines article also helped influence the choice as I'd like to go over that to get some automated deployments going. Presently any docker related changes are manually managed on the server with docker-compose commands, while project code is managed with git(and GitLab), it's sync'd to the project folders by the devs when they have production updates.

fgilio commented 5 years ago

Hmmm I don't really have a lot of experience in this front. One thing that comes to mind if that using an FPM enabled version of the PHP image would be all that's required. Sorry I can't be of more help, I'll be following the discussion closely.

8ctopus commented 4 years ago

I was facing the same limitation with Loris' docker image so I created another docker image which adds apache and php-fpm. if interested you can check it out here https://github.com/8ctopus/apache-php-fpm-alpine.

sean7218 commented 4 years ago

can i use this image for production on AWS with artisan serve?