Hi everyone,
After spending two full days trying to get Flarum up and running using Docker setup (PHP-FPM + Caddy), I wanted to share my experience. I am not an IT professional and I don't know anything about php.
I just share what I understood about it for others.
### Initial setup
I used this Dockerfile
FROM php:8.3-fpm
RUN apt-get update && apt-get install -y \
curl \
git \
unzip \
libzip-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install zip pdo pdo_mysql gd \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www/html
because gd is required.
I set up a docker compose with mariadb and connected it on the network of my pre-existing caddy docker.
I used the Caddyfile from documentation and installed flarum with composer inside the docker instance.
Installation fails on PHP 8.3 with flarum/flarum:1.8.0 due to deprecated string syntax
PHP Deprecated: Using ${var} in strings is deprecated, use {$var} instead
in /var/www/html/vendor/flarum/core/migrations/2022_05_20_000000_add_timestamps_to_groups_table.php on line 23
...
PHP Fatal error: Uncaught Laminas\HttpHandlerRunner\Exception\EmitterException:
Unable to emit response; headers already sent
As a result:
- The database was populated
- No
config.php is created
- On reload, the installer reappeared.
I solved this by downgrading FROM php:8.3-fpm to FROM php:8.1-fpm
Caddy
I also had trouble with Caddy
monurl.org {
root * /var/www/html/public
php_fastcgi flarum_php:9000
header /assets/* {
+Cache-Control "public, must-revalidate, proxy-revalidate"
+Cache-Control "max-age=25000"
Pragma "public"
}
file_server
}
If I understand well, flarum is a kind of SPA so I tried this and even if caddy php_fastcgi directive is supposed to handle that I tried :
rewrite * /index.php
allowing to access the install form by accessing / ; but after the install I got 404 http codes.
Then:
try_files {path} {path}/ /index.php
But even with that, Caddy served 404s for real files like /index.php and /assets/forum.css until I verified that the root path matched the real mount in the container, and that the files actually existed.
Now, I just give up.
I hope this post saves someone else hours of frustration 🙏
Happy to provide more details if needed.
Cheers,
Romain