re-write Dockerfile

This commit is contained in:
Zero 2024-10-29 23:06:50 +08:00
parent e4ca3bf132
commit 4b60c03caa
1 changed files with 30 additions and 30 deletions

View File

@ -1,11 +1,7 @@
FROM php:8.3-apache FROM php:8.3-apache
ENV APACHE_DOCUMENT_ROOT /app/public
WORKDIR /app
RUN <<EOR
# Install additional dependencies # Install additional dependencies
apt-get update RUN apt-get update && \
apt-get install -y \ apt-get install -y \
git \ git \
zip \ zip \
@ -13,22 +9,26 @@ apt-get install -y \
libpng-dev \ libpng-dev \
libldap2-dev \ libldap2-dev \
libzip-dev \ libzip-dev \
wait-for-it wait-for-it && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Configure apache # Install PHP extensions
docker-php-ext-configure ldap --with-libdir="lib/$(gcc -dumpmachine)" RUN docker-php-ext-configure ldap --with-libdir="lib/$(gcc -dumpmachine)" && \
docker-php-ext-install pdo_mysql gd ldap zip docker-php-ext-install pdo_mysql gd ldap zip && \
pecl install xdebug pecl install xdebug && \
docker-php-ext-enable xdebug docker-php-ext-enable xdebug
a2enmod rewrite
sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Install composer # Install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Configure apache
RUN a2enmod rewrite && \
sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Use the default production configuration and update it as required # Use the default production configuration and update it as required
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
sed -i 's/memory_limit = 128M/memory_limit = 512M/g' "$PHP_INI_DIR/php.ini" sed -i 's/memory_limit = 128M/memory_limit = 512M/g' "$PHP_INI_DIR/php.ini"
EOR
ENV APACHE_DOCUMENT_ROOT /app/public
WORKDIR /app