I'm creating a custom docker image. I want to configure the image for the GLPI system. I have already installed some PHP extensions. I want to install the php-cli extension now.
There are php-cli docker images, but they do not contain the Apache server. I want to create an image with Apache and the necessary PHP extensions. Can you help me ?
Dockerfile used so far:
FROM php:8.3.2-apache-bookworm
# Definition of variables
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Sao_Paulo \
LANG=pt_BR.utf8 \
LANGUAGE=pt_BR:pt \
LC_ALL=pt_BR.UTF-8
# Timezone and locales configuration
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& apt-get update && apt-get install -y locales && localedef -i pt_BR -c -f UTF-8 -A /usr/share/locale/locale.alias $LC_ALL
# Installing additional packages
RUN apt-get install -y wget nano iproute2 iputils-ping
# Installing libraries required to install additional PHP extensions
RUN apt-get install -y libxml2-dev libc-client-dev libkrb5-dev libldap2-dev libcurl4-openssl-dev \
libsnmp-dev libzip-dev libpng-dev libonig-dev libbz2-dev libjpeg-dev libxml2-dev libfreetype6-dev
# Installing additional extensions - Docker Script
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install bz2 curl exif gd ldap imap intl mbstring mysqli opcache soap snmp xml zip
# Installing additional extensions - Pecl Command
RUN pecl install apcu \
&& pecl install channel://pecl.php.net/xmlrpc-1.0.0RC3 xmlrpc \
&& docker-php-ext-enable apcu xmlrpc
# Downloads the specified GLPI Version and unzips it to the web directory
RUN wget -O- https://github.com/glpi-project/glpi/releases/download/10.0.11/glpi-10.0.11.tgz | tar -zxv --strip-components=1 -C /var/www/html/ \
&& chown www-data:www-data -R /var/www/html \
&& find /var/www/html -type d -exec chmod 755 {} \; \
&& find /var/www/html -type f -exec chmod 644 {} \; \
&& apt-get purge -y wget
# Disable the default website and enable the GLPI website and required Apache modules
COPY glpi.conf /etc/apache2/sites-available/glpi.conf
RUN a2dissite 000-default.conf \
&& a2ensite glpi.conf \
&& a2enmod rewrite \
&& a2enmod headers
# Clean up downloaded packages, remove no longer used dependencies, and remove package lists
RUN apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
# Create the container with the user www-data
USER www-data