wyveo / nginx-php-fpm

Nginx + PHP-FPM 8.2.x / 8.1.x / 8.0.x / 7.4.x / 7.3.x / 7.2.x / 7.1.x / 7.0.x + Composer built on Debian (Bullseye/Buster) image
https://hub.docker.com/r/wyveo/nginx-php-fpm
MIT License
342 stars 245 forks source link

Web Server Root Path #60

Open excalq opened 2 years ago

excalq commented 2 years ago

First I'd like to pay a compliment to the very well put together Docker base image you've created. Nicely done, and thank you.

Regarding /usr/share/nginx/html, as the web root directory, though this may sound very pedantic, I wanted to point out a bit of history informing the choice of web root paths, which are typically /var/www in most Linux distributions, including Debian. In contrast, this project uses /usr/share/nginx/html, the Nginx package's installed location for default HTML files.

In the 1994 Filesystem Hierarchy Standard[0] (The "standard guidelines for file and directory placement under UNIX-like operating systems"), it's noted that:

/var contains variable data files [...] /var is specified here in order to make it possible to mount /usr read-only. Everything that once went into /usr that is written to during system operation (as opposed to installation and software maintenance) must be in /var.

However, note that Nginx does correctly use /usr/share as the location to place it's "read-only" package installed data/sample files.[1]

Any program or package which contains or requires data that doesn't need to be modified should store that data in /usr/share. [...] It is recommended that a subdirectory be used in /usr/share for this purpose.

The FHS Standard makes this example for games:

Game data stored in /usr/share/games must be purely static data. Any modifiable files, such as score files, game play logs, and so forth, should be placed in /var/games.

An insightful discussion can be found on StackOverflow[2].

[0] https://www.pathname.com/fhs/pub/fhs-2.3.html#PURPOSE31 [1] https://www.pathname.com/fhs/pub/fhs-2.3.html#USRSHAREARCHITECTUREINDEPENDENTDATA [2] https://unix.stackexchange.com/questions/47436/why-is-the-root-directory-on-a-web-server-put-by-default-in-var-www

excalq commented 2 years ago

All that said, it's easy enough to just override the web root in one's own Nginx config, in a Dockerfile that extends this project's image:

FROM wyveo/nginx-php-fpm:php81
...
COPY . /var/www

COPY ./docker-files/nginx.conf /etc/nginx/conf.d/website.conf
RUN rm -rf /etc/nginx/conf.d/default.conf

Perhaps an example in the README.md could illustrate this well. I'll be happy to contribute mine when it's ready. It also does npm install and composer install during the build. This would help resolve issue #40 as well.