Search code examples
dockersymfonyfpm

Docker run symfony on PHP-FPM


How can I install all needed php extension on this docker image to run symfony 5. At this moment I can't run composer install cos following error.

Problem 1 - Installation request for lorenzo/pinky 1.0.5 -> satisfiable by lorenzo/pinky[1.0.5]. - lorenzo/pinky 1.0.5 requires ext-xsl * -> the requested PHP extension xsl is missing from your system. Problem 2 - lorenzo/pinky 1.0.5 requires ext-xsl * -> the requested PHP extension xsl is missing from your system. - twig/inky-extra v3.0.5 requires lorenzo/pinky ^1.0.5 -> satisfiable by lorenzo/pinky[1.0.5]. - Installation request for twig/inky-extra v3.0.5 -> satisfiable by twig/inky-extra[v3.0.5].

My Dockerfile.

FROM php:7.4-fpm

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        nano \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

RUN curl --insecure https://getcomposer.org/download/1.10.19/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer

# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
RUN "date"

WORKDIR /var/www/symfony

I tried to add following install command to dockerfile "php7.4-xsl" but then I had follwoing error:

E: Unable to locate package php7.4-xsl E: Couldn't find any package by glob 'php7.4-xsl' E: Couldn't find any package by regex 'php7.4-xsl'

composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "composer/package-versions-deprecated": "^1.11",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "2.1.2",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.7",
        "knpuniversity/oauth2-client-bundle": "^2.4",
        "league/html-to-markdown": "^4.10",
        "league/oauth2-google": "^3.0",
        "league/oauth2-linkedin": "^5.1",
        "phpdocumentor/reflection-docblock": "^5.2",
        "sensio/framework-extra-bundle": "^5.6",
        "symfony/asset": "5.1.*",
        "symfony/console": "5.1.*",
        "symfony/dotenv": "5.1.*",
        "symfony/expression-language": "5.1.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.1.*",
        "symfony/framework-bundle": "5.1.*",
        "symfony/http-client": "5.1.*",
        "symfony/intl": "5.1.*",
        "symfony/mailer": "5.1.*",
        "symfony/messenger": "5.1.*",
        "symfony/mime": "5.1.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "5.1.*",
        "symfony/process": "5.1.*",
        "symfony/property-access": "5.1.*",
        "symfony/property-info": "5.1.*",
        "symfony/security-bundle": "5.1.*",
        "symfony/serializer": "5.1.*",
        "symfony/string": "5.1.*",
        "symfony/translation": "5.1.*",
        "symfony/twig-bundle": "5.1.*",
        "symfony/validator": "5.1.*",
        "symfony/web-link": "5.1.*",
        "symfony/webpack-encore-bundle": "^1.7",
        "symfony/yaml": "5.1.*",
        "symfonycasts/verify-email-bundle": "^1.0",
        "twig/cssinliner-extra": "^3.0",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/inky-extra": "^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.3",
        "symfony/browser-kit": "^5.1",
        "symfony/css-selector": "^5.1",
        "symfony/debug-bundle": "^5.1",
        "symfony/maker-bundle": "^1.21",
        "symfony/phpunit-bridge": "^5.1",
        "symfony/stopwatch": "^5.1",
        "symfony/var-dumper": "^5.1",
        "symfony/web-profiler-bundle": "^5.1"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.1.*"
        }
    }
}

So how can I install all needed modules?

Thank you


Solution

  • You'll need to install all extensions needed manually. In your case, you are missing the XSL extension. This should at least fix the XSL issue.

    FROM php:7.4-fpm
    
    RUN apt-get update && apt-get install -y \
            libfreetype6-dev \
            libjpeg62-turbo-dev \
            libpng-dev \
            nano \
            libxslt1.1 \
            libxslt1-dev \
            unzip \
            git \
        && docker-php-ext-configure gd --with-freetype --with-jpeg \
        && docker-php-ext-install -j$(nproc) gd xsl
    
    RUN curl --insecure https://getcomposer.org/download/1.10.19/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer
    
    # Set timezone
    RUN rm /etc/localtime
    RUN ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
    RUN "date"
    
    WORKDIR /var/www/symfony
    

    EDIT:

    I had to add git and unzip in order to be able to install everything, but it did work. Make sure you don't miss the xsl in the docker-php-ext-install statement.