GitHub - timo-reymann/php-app: Docker image for running PHP apps in a single con...
source link: https://github.com/timo-reymann/php-app
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
php-app
Docker image for running PHP apps in a single container with nginx and PHP-fpm
Components
The image consists of:
- multirun - Small util for executing multiple processes with proper signal handling
- PHP 8 FPM - Execution of PHP files
- nginx - Serve evaluated files from FPM
PHP 8 extensions that are common are also pre-installed:
- mysqli
- freetype
- pdo_mysql
- opcache
Ports
- 8080: HTTP-Server
Usage
Basic
For basic usage with no further extensions, you just copy your sources to /app
FROM timoreymann/php-app
COPY --chown=application:application ./code /app
Build your image with sources and install composer dependencies
When you use composer for external dependencies you can easily install them in the build process.
The composer-install
script downloads the installer from GitHub, installs the depencies and removes the phar file.
FROM timoreymann/php-app
WORKDIR /app
COPY --chown=application:application ./code ./
RUN composer-install
Configure index.php for PHP-based routing
When you build a modern web app with PHP, chances are high that you will have routing within your index.php. To make it work, nginx needs to route all requests to the index.php, if the file does not exist in the webroot (e.g. assets).
FROM timoreymann/php-app
WORKDIR /app
COPY --chown=application:application ./code ./
RUN composer-install && configure-index-rewrite
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK