I have created a Dockerfile (with great help of GPT) that should install composer, symfony-cli, git and mysqli, but I am getting “command not found” for all of them.
I can install all above mentioned tools with exactly the same commands in bash terminal after building the container, but I would like to avoid doing it every time when I need to rebuild the container.
What should be changed to make it working?
FROM php:8.2-fpm
# Install system dependencies
RUN apt update && apt upgrade && apt install -y
libfreetype6-dev
libjpeg62-turbo-dev
libpng-dev
libonig-dev
libxml2-dev
zip
unzip
git
curl
gnupg
# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt install -y nodejs
# Clear cache
RUN apt clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install -j$(nproc) gd
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install exif
RUN docker-php-ext-install pcntl
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install opcache
RUN docker-php-ext-install intl
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN docker-php-ext-install pdo && docker-php-ext-enable pdo
RUN docker-php-ext-install pdo_mysql && docker-php-ext-enable pdo_mysql
RUN docker-php-ext-install soap
RUN docker-php-ext-install zip
RUN docker-php-ext-install calendar
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
# Install Symfony CLI
RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony*/bin/symfony /usr/local/bin/symfony
# Set working directory
WORKDIR /var/www
# Copy existing application directory permissions
COPY --chown=www-data:www-data . /var/www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]