mySQL on DOCKER (with PHP Symfony for MERCURE bundle)

89 Views Asked by At

I have a problem with MySQL in Docker, by default Docker uses PostgreSQL, so I have created a MySQL image but when I launch my Dockerfile, I have some errors, in particular — problems with installing PDO.

I tried to change my Dockerfile, my docker-compose.yml (for the logs, user : root and no password) but i have the same problem

# Utilisez l'image PHP avec Apache et extensions MySQL

FROM php:8.1-apache

# Définir le répertoire de travail

WORKDIR /var/www/

# Copiez les fichiers du projet dans le conteneur

COPY . /var/www/

# Installez les dépendances du système

RUN apt-get update && apt-get install -y \
    libicu-dev \
    libzip-dev \
    zip \
    unzip \
    && docker-php-ext-install -j$(nproc) intl pdo_mysql zip gd

# Installez Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Installez Composer
RUN curl -sS https://deb.nodesource.com/setup_14.x | bash -

# Installez les dépendances Node.js et NPM
RUN apt-get update && apt-get install -y \
    curl \
    gnupg2 \
    && curl -sL https://deb.nodesource.com/setup_14.x | bash - \
    && apt-get install -y nodejs

# Installez les dépendances du projet avec Composer
RUN composer install --ignore-platform-req=ext-gd

# Installez les dépendances du projet avec NPM
# RUN npm install
# Activez le module Apache pour les réécritures d'URL
RUN a2enmod rewrite

# Exposez le port d'écoute d'Apache
EXPOSE 80

# Démarrez Apache lorsque le conteneur est lancé
CMD ["apache2-foreground"]

Error that I have:

ERROR [php 5/11] RUN docker-php-ext-configure gd --with-png-dir=/usr -- 8.8s ---­ [php 5/11] RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr: 5.537 Configuring for: 5.537 PHP Api Version: 20210902 5.537 Zend Module Api No: 20210902 5.537 Zend Extension Api No: 420210902 7.326 configure: error: unrecognized options: --with-png-dir, --with-jpeg-dir ------ failed to solve: process "/bin/sh -c docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr" did not complete successfully: exit code: 1

1

There are 1 best solutions below

2
Rick Rackow On

There's been a bit of change by php. So you'll have to adjust following the conversation on their GitHub repo.

One way that will work is the following:

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