tiredofit / docker-nginx-php-fpm

Dockerized web server and interpreter image with many customizable options
MIT License
138 stars 34 forks source link

02-pdo_pgsql.ini file not generated #46

Closed mrokitka closed 1 year ago

mrokitka commented 1 year ago

Summary

Using tiredofit/nginx-php-fpm:alpine-8.1 (same behavior experienced in the debian image) the PHP file for PDO PostgreSQL integration is not being generated, so PDO does not work for PG (PHP reports an error that the driver is not present).

If you add the file manually to the image at /etc/php81/conf.d/02-pdo_pgsql.ini with the following contents, it works as expected:

extension=pdo_pgsql ;priority=02

Steps to reproduce

Just run the container with default options of PostgreSQL support enabled.

What is the expected correct behavior?

Container should automatically generate this file so that PG can be used from PDO.

Relevant logs and/or screenshots

N/A

Environment

Possible fixes

tiredofit commented 1 year ago

Thanks, Let me look into this in coming days and get this back on track.

tiredofit commented 1 year ago

Just looking into this now - I see that there is a symbolic link created for 01-pdo_pgsql.ini but not 02-pdo_pgsql.ini as you have referenced. I'm having trouble recreating it as I see its loading on my end:

17:45:46 [dave:~]└3 $ docker run -it -e PHP_ENABLE_PDO_PGSQL=TRUE tiredofit/nginx-php-fpm bash
                                                                       ,---.
,--------.,--.                 ,--.            ,---.    ,--. ,--------.|   |
'--.  .--'`--',--.--. ,---.  ,-|  |     ,---. /  .-'    |  | '--.  .--'|  .'
   |  |   ,--.|  .--'| .-. :' .-. |    | .-. ||  `-,    |  |    |  |   |  |
   |  |   |  ||  |   \   --.\ `-' |    ' '-' '|  .-'    |  |.--.|  |   `--'
   `--'   `--'`--'    `----' `---'      `---' `--'      `--''--'`--'   .--.
                                                                       '--'
Image:  tiredofit/nginx-php-fpm
Repository/Issues/Support:  https://github.com/tiredofit/docker-nginx-php-fpm/
           Sponsor me for development and upkeep: https://www.tiredofit.ca/sponsor
++ set -o posix
++ set
++ sort
++ grep PHP_ENABLE_
++ grep -i TRUE
++ sed -e s/PHP_ENABLE_//g
++ sed -e s/=TRUE//g
++ awk -vRS= '-vOFS=, ' '$1=$1'
++ tr A-Z a-z
+ php_env_plugins_enabled='apcu, bcmath, bz2, ctype, curl, dom, exif, fileinfo, gd, iconv, imap, intl, mbstring, mysqli, mysqlnd, opcache, openssl, pdo, pdo_mysql, pdo_pgsql, pgsql, phar, session, simplexml, tokenizer, xml, xmlreader, xmlwriter'
++ echo 'apcu, bcmath, bz2, ctype, curl, dom, exif, fileinfo, gd, iconv, imap, intl, mbstring, mysqli, mysqlnd, opcache, openssl, pdo, pdo_mysql, pdo_pgsql, pgsql, phar, session, simplexml, tokenizer, xml, xmlreader, xmlwriter'
Enabling pdo
Enabling pdo
Enabling pdo_mysql
Enabling pdo_mysql
Enabling pdo_pgsql
Enabling pdo_pgsql
Enabling pgsql
Enabling pgsql
2023-01-07.01:45:50 [NOTICE] ** [php-fpm] PHP-FPM Preparing to start with the following plugins enabled:  apcu bcmath bz2 ctype curl dom exif fileinfo gd iconv imap intl mbstring mysqli mysqlnd opcache openssl pdo pdo_mysql pdo_pgsql pgsql phar session simplexml tokenizer xml xmlreader xmlwriter
2023-01-07.01:45:50 [STARTING] ** [php-fpm] [1] Starting php-fpm 8.1.14
2023-01-07.01:45:50 [STARTING] ** [scheduling] [1] Starting cron
[tiredofit/nginx-php-fpm 01:45:50 /] $ ls -l /etc/php81/conf.d/*pgsql*
lrwxrwxrwx    1 root     www-data        35 Jan  7 01:45 /etc/php81/conf.d/00-pgsql.ini -> /etc/php81/mods-available/pgsql.ini
lrwxrwxrwx    1 root     www-data        39 Jan  7 01:45 /etc/php81/conf.d/01-pdo_pgsql.ini -> /etc/php81/mods-available/pdo_pgsql.ini

[tiredofit/nginx-php-fpm 01:46:05 /] $ cat /etc/php81/conf.d/01-pdo_pgsql.ini 
extension=pdo_pgsql
;priority=01

[tiredofit/nginx-php-fpm 01:49:32 /] $ php -m | grep pgsql
pdo_pgsql
pgsql

I don't believe its going to cause a problem if its being loaded as 01 or 02. In fact, I read the ;priority command from the files and then make the symlinked prefixed name based on that value.

I have one of my popular images with Postgresql support for the past month'ish' with no other reports - Do you have anything that I can test on briefly?

mrokitka commented 1 year ago

I see, perhaps this is a documentation issue then. I didn't realize that specifying that env var was required, as it's not mentioned anywhere in the docs under "Enabling / DIsabling Specific Extensions". Is there a reason PG must be explicitly enabled, but the MySql PDO is enabled by default?

tiredofit commented 1 year ago

Personal preference really. I use this as a base image and have a set of defaults that mostly works - When need arises I enable the modules that would deviate from the defaults, which happens every once in in a while..

You can head inside the container and see what modules are available by typing php-ext list all and then the list that comes up you would simply add PHP_ENABLE_(module_name)=TRUE and it will be enabled on startup. Theoretically it makes for a leaner system..

If you are developing with this and using it as a base image and needing to do things like use composer in the Dockerfiles I generally set the environment variables and before running composer i execute php-ext enable core which will enable the modules within the Docker build environment and avoid any module not found errors.

Of course if you don't care about any of that there is always PHP_KITCHENSINK=TRUE which is everything including the kitchen sink (all modules available). It's been a while since I've used that personally. I hope this helps..

tiredofit commented 1 year ago

It looks like there may have been something else that I may have missed. I just reviewed and accepted PR #47 which targets not being able to enable modules with an underscore in them. Perhaps now with this fresh build things may work for you as expected? Or maybe this is just a well timed coincidence.

mrokitka commented 1 year ago

Things are working now as anticipated. I think this is all set.

Thanks!

terryzwt commented 1 year ago

The ENV PHP_ENABLE_PDO_PGSQL not list on the README, only PHP_ENABLE_PGSQL.