I recently started setting up a dockerized October CMS environment based on Alpine Linux, MariaDB and PHP-FPM which was actually a very straightforward process. However, for some reason the integrated image resizer didn’t create thumbnails of uploaded images.
Unfortunately there was nothing in the log files which could help me to identify the cause of the problem. After checking the file permissions, I decided to trace back the issue and found the reason in file vendor/october/rain/src/Database/Attach/Resizer.php.
The method getMimeType() returned always null, which broke the entire image manipulation process.
// Get the file extension
$this->extension = $file->guessExtension();
$this->mime = $file->getMimeType();
After a quick research I found out that getMimeType requires php_fileinfo which I simply forgot to set in my Dockerfile. After adding php7-fileinfo and rebuilding the container, the issue was finally fixed.
Today I finally had some time to cleaned up my Dockerfile for Magento 2. I am using Alpine Linux for most of my Magento 2 projects which usually includes NGINX, PHP-FPM and MariaDB.
# Use Alpine Linux
# Declare maintainer
MAINTAINER Tobias Forkel <firstname.lastname@example.org>
ENV TIMEZONE Australia/Melbourne
RUN addgroup -g 1000 www && \
adduser -S www -G www -s /sbin/nologin -D
ADD https://repos.php.earth/alpine/phpearth.rsa.pub /etc/apk/keys/phpearth.rsa.pub
RUN echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories
RUN apk --no-cache add \
While testing my updated Dockerfile I came across the following PHP notice which prevented the deployment scripts from finishing the Magento 2 setup.
Notice: Use of undefined constant T_CURLY_OPEN - assumed 'T_CURLY_OPEN' in /var/www/src/setup/src/Magento/Setup/Module/ Di/Code/Reader/FileClassScanner.php on line 72
The problem was simply a missing PHP extension php7.1-tokenizer which has resolved the issue after re-creating the container with –build.
docker-compose up -d --build
Today I successfully installed my first October CMS project locally via composer / command line. The installation was pretty straightforward and worked surprisingly well on my Alpine Linux docker container which includes NGINX, PHP-FPM and MariaDB.
- v1.0.1: First version of Demo
,,,. ,@@@@@@/@@, .oo8888o.
%&&%/ %&%%&&@@\ V /@@' `88\8 `/88'
`&%\ ` /%&' |.| \ '|8'
|o| | | | |
|.| | | | |
`========= INSTALLATION COMPLETE ========='
However, when I tried to open the front-end I got the following error.
PHP message: PHP Fatal error: Interface 'SessionHandlerInterface' not found in /var/www/src/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php on line 10
After a quick research I found the solution on Stackoverflow. I basically forgot to install the PHP extension php7-session inside my docker container. I manually installed the missing extension, but also updated my Dockerfile in case I have to rebuild my container.
bash-4.4# apk add php7-session
(1/1) Installing php7-session (7.1.33-r0)
OK: 291 MiB in 87 packages
After that I manually killed all PHP processes to make sure php-fpm loads the new extension with the next page reload.