Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bkuhl/fpm-nginx
A single container with fpm & nginx with Laravel dependencies
https://github.com/bkuhl/fpm-nginx
docker laravel nginx php php-fpm
Last synced: 1 day ago
JSON representation
A single container with fpm & nginx with Laravel dependencies
- Host: GitHub
- URL: https://github.com/bkuhl/fpm-nginx
- Owner: bkuhl
- License: mit
- Created: 2017-05-01T18:52:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-28T12:44:10.000Z (12 months ago)
- Last Synced: 2023-11-28T13:43:09.958Z (12 months ago)
- Topics: docker, laravel, nginx, php, php-fpm
- Language: Dockerfile
- Homepage:
- Size: 108 KB
- Stars: 49
- Watchers: 3
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FPM/Nginx - [Dockerhub Repo](https://hub.docker.com/r/bkuhl/fpm-nginx/)
This container is intended to run Laravel applications and thus comes with a few items to assist:
* [Composer](https://getcomposer.org)
* PHP Extensions
* [mbstring](http://php.net/manual/en/book.mbstring.php)
* [pdo_mysql](http://php.net/manual/en/ref.pdo-mysql.php)
* [gd](http://php.net/manual/en/book.image.php)
* [opcache](http://php.net/manual/en/book.opcache.php) - Automatically enabled when `APP_ENV=production`
* [xdebug](https://xdebug.org) - Only enabled when `XDEBUG_ENABLE=true`. Only installed when `XDEBUG_ENABLE=true` when building the container
* Adding a default virtual host serving apps from `/var/www/html/public`
For Laravel applications, see [bkuhl/laravel-fpm-nginx](https://github.com/bkuhl/laravel-fpm-nginx).For a container to run cron and other CLI tasks, check out [bkuhl/php](https://github.com/bkuhl/php).
**Why 2 processes in 1 container?**
1. DNS issues - Both the fpm/nginx containers need to be redeployed when your application is updated. Nginx maintains an internal DNS cache, so while Docker may ensure zero downtime for fpm containers, nginx's internal workings can still create problems. The only way to solve this (that I've found) is to restart the nginx process. Having them on the same container eliminates the problem.
2. Laravel Mix - The front/backend of applications are kind of coupled when using something like Laravel Mix. The index of assets it creates need to be on both containers and running these separately is possible, but redundant.## Adding Processes
This container uses [S6 Overlay](https://github.com/just-containers/s6-overlay) as it's process monitoring solution. Add a new directory to `services.d` with a `run` file in it where `run` in a shell script that kicks off the process. The rest is taken care of for you.
## Example Dockerfile
```
FROM bkuhl/fpm-nginx:latestWORKDIR /var/www/html
# Copy the application files to the container
ADD --chown=www-data:www-data . /var/www/htmlUSER www-data
RUN composer install --no-interaction --optimize-autoloader --no-dev --no-cache --prefer-dist
```