I am using a lightly modified version of the API Platform Symfony environment. Since part of the postgres system built into that environment is not working for me right now, I'm falling back to using sqlite as the database provider.
I somewhat predictably get An exception occurred in the driver: could not find driver
when loading any of my Symfony app's database-connected pages in the browser. That makes sense, since the docker compose setup is not by default configured to use sqlite.
What's surprising to me is how difficult it is to actually get the driver installed on the machine in question. Based on info seen in some other questions/answers, here's what I've tried adding to the Dockerfile, without success:
RUN apt update && apt upgrade -y
RUN apt-get install -y ca-certificates apt-transport-https
RUN apt-get install -y software-properties-common
RUN apt-get install -y python3-launchpadlib
RUN add-apt-repository http://archive.ubuntu.com/ubuntu noble-updates/main
RUN add-apt-repository ppa:ondrej/php
RUN apt update
RUN apt upgrade
RUN apt install -y php7.3-sqlite3
RUN rm -rf /var/lib/apt/lists/*
Unfortunately, this yields the following output when doing a docker compose build --no-cache
:
=> ERROR [php frankenphp_base 9/17] RUN apt update 0.8s
------
> [php frankenphp_base 9/17] RUN apt update:
0.150
0.150 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.150
0.223 Hit:1 http://deb.debian.org/debian bookworm InRelease
0.225 Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
0.239 Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
0.345 Ign:4 https://ppa.launchpadcontent.net/ondrej/php/ubuntu bookworm InRelease
0.372 Err:5 https://ppa.launchpadcontent.net/ondrej/php/ubuntu bookworm Release
0.372 404 Not Found [IP: 185.125.190.80 443]
0.452 Reading package lists...
0.763 E: The repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu bookworm Release' does not have a Release file.
------
failed to solve: process "/bin/sh -c apt update" did not complete successfully: exit code: 100
Anybody know a sneaky way of getting this elusive package (or a functional equivalent) installed?
===
EDIT: I realized somewhat belatedly that I was barking up the wrong tree. My app was being served via symfony serve
on my host system, not within the docker container. As soon as I realized that, I verified that the php-sqlite3
apt package had already been installed. After that, it was a simple matter of un-commentating the line in my php.ini
file that said ;extension=pdo_sqlite
and after a restart of my symfony serve
command ... presto! Everything worked!
For a PHP extension (module) to be available, it must
.so
on Linux) andInstalling the binary:
install-php-extensions pdo_sqlite
Activating the binary (official PHP docker images):
docker-php-ext-enable pdo_sqlite
This is equivalent to using the systems package manager and telling PHP to load the ini-configuration with an extension=<ext-name> directive.
Some extensions that are Zend extensions need the zend_extension directive instead.
For PECL extensions, the pecl utility becomes the "package manager".
Now in your question you're making use of multiple things to install the extension and that is probably part of the confusion:
In case this is some kind of shotgun debugging, the install-php-extensions script should suffice. According to FrankenPHP #845 they build on-top the official PHP images and use docker-php-extension-installer which is also designed for official setups.
I'd isolate the case and use that script only without running the package managers etc. as it is originally outlined in the FrankenPHP documentation and see if it works.
If there are additional requirements via the package manager, I'd keep that separated and only when all things work in isolation, bring them more close together (if at all).
References