- Changes nginx config path from `/etc/nginx/conf.d/*.conf` to `/etc/nginx/http.d/*.conf` as this was altered in Alpine 3.14/15
- Pins dependencies to their major versions
- Changes default location from `/var/www/html` to `/var/www/html/public`, this will allow Laravel applications to use the same nginx config without the need to change anything.
- Changes nginx landing page to PHP Info
- Improved OPcache performance by allowing more memory
- Remove build cache when finished to reduce image size
- Moved opcache config from the Dockerfile to a separate `ini` file, enabled JIT compiling
- Expire static asset caching after 30 days in nginx config
- Deny access to non-site or public assets in nginx config
- Turns off nginx version info on publicly accessible pages
- Due to Docker autobuilds becoming a paid service, the `latest` tag will now be built via GitHub Actions on any push to the main branch.
- Updates various pieces of documentation
## 6 (2021-02-27)
- Removes `server_name` from nginx.conf as it's not needed
## 5 (2021-02-08)
- Adds `Composer` to the image out of the box
- Set explicit shell
## 4 (2021-02-06)
- Dropped support for PHP 7.0 - 7.3 due to GD changes that cannot build properly under those versions
- Switched from Travis CI to GitHub Actions
- Adopted new release workflow where each change simply iterates the version number since we provide images for various PHP versions
The following features work out of the box without any configuration:
-`PHP-FPM/OPcache` for fast performance in the browser and on the CLI
-`Nginx` serves as the web host and reverse proxy
-`msmtp` is installed and configured (see `config/msmtprc`) to send mail locally for testing via apps like `Mailcatcher` which will work out of the box (if Mailcatcher container is titled `mailcatcher`)
-`mysql_pdo` is installed as the driver for database connections
-`gd` is installed for image processing
-`zip` is installed for items that may need that
-`composer` is installed and ready to use to setup all your dependencies
## Platforms
This image offers platform support for the following architectures starting from image version `8`:
- linux/amd64
- linux/arm/v7
- linux/arm64
## Install
```bash
# Dockerfile
FROM: justintime50/nginx-php:latest
# docker-compose
image: justintime50/nginx-php:latest
```
## Usage
**Vanilla PHP and HTML**
Place your `PHP` or `HTML` site files into `/var/www/html/public` inside the container to get started with this image. This can be achieved by using a volume in a `docker-compose` file or by copying them over in a `Dockerfile`. If you are using HTML instead of PHP, ensure you remove the `index.php` file so that your `index.html` file can take priority.
**Laravel**
Place the root of your laravel project in `/var/www/html` so that the `public` folder of laravel lines up with the directory served by this nginx image (see `examples/laravel` for more details).
Want to give this image a spin? Simply run the following:
```bash
docker compose up -d
```
Once the container spins up, navigate to `http://localhost:8888` in a browser.
## Docker Tags
Tags for this image follow the syntax of `PHP_VERSION-IMAGE_VERSION`; for instance, a valid tag would be `7.4-9` signifying to use PHP v7.4 and the 9th version of this image (nginx config, Dockerfile, etc).
**PHP Versions**
-`8.1` - uses the latest release on the PHP 8.1 Alpine track. (Starting with image version `9`)
-`8.0` - uses the latest release on the PHP 8.0 Alpine track.
-`7.4` - uses the latest release on the PHP 7.4 Alpine track.
**Image Versions (see CHANGELOG for more details)**
-`10`
-`9`
-`8`
-`7`
**Standalone Tags**
-`latest` - uses the latest release of this image with all defaults.
-`dev` - the testing branch for this image. Do not use this tag in production.
## Development
**Note:** Alpine Linux does not keep old versions of packages. This image pins to the relative major version to try staying flexibile. Future builds may need to be altered if packages are no longer offered.
```bash
# Test nginx configuration
nginx -T
```
**Releasing**
When releasing this project, cut a new GitHub tag/release that simply iterates the number (eg: 4, 5, 6...). We won't use semver here for simplicity when tagging images.
### Building New Versions
This image supports swapping in the version number of PHP with a value from the official `PHP-FPM Alpine`[tag list](https://hub.docker.com/_/php).
**Automated Builds**
GitHub Actions will automatically build and push supported tags to Docker Hub on each new release. Additionally GitHub Actions will automatically build the `latest` tag on any push to the main branch. It is highly recommended that you use a versioned release of this image to avoid any transient changes introduced in any given `latest` build.