53 lines
1.9 KiB
Docker
53 lines
1.9 KiB
Docker
|
|
FROM php:apache
|
||
|
|
|
||
|
|
# Build-time deps for PHP extensions
|
||
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
|
|
libicu-dev libzip-dev libpng-dev libjpeg62-turbo-dev libfreetype6-dev \
|
||
|
|
libxml2-dev libcurl4-openssl-dev libonig-dev pkg-config unzip git tzdata \
|
||
|
|
&& docker-php-ext-configure gd --with-jpeg --with-freetype \
|
||
|
|
&& docker-php-ext-install -j"$(nproc)" \
|
||
|
|
pdo pdo_mysql mysqli intl zip gd bcmath mbstring curl xml \
|
||
|
|
&& a2enmod rewrite headers \
|
||
|
|
&& rm -rf /var/lib/apt/lists/*
|
||
|
|
|
||
|
|
# Composer from official image
|
||
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||
|
|
|
||
|
|
# Configure Apache to listen on port 7876
|
||
|
|
RUN sed -i 's/Listen 80/Listen 7876/' /etc/apache2/ports.conf \
|
||
|
|
&& sed -i 's/<VirtualHost \*:80>/<VirtualHost *:7876>/' /etc/apache2/sites-available/000-default.conf
|
||
|
|
|
||
|
|
# Set Apache DocumentRoot to /var/www/html/public
|
||
|
|
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf
|
||
|
|
|
||
|
|
# Apache request timeout
|
||
|
|
RUN echo "Timeout 300" > /etc/apache2/conf-available/timeouts.conf && a2enconf timeouts
|
||
|
|
|
||
|
|
# PHP config
|
||
|
|
COPY docker/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||
|
|
|
||
|
|
WORKDIR /var/www/html
|
||
|
|
|
||
|
|
# Copy application source
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Install Composer dependencies
|
||
|
|
RUN composer install --no-interaction --prefer-dist --no-dev --optimize-autoloader
|
||
|
|
|
||
|
|
# Base permissions: code owned root:www-data, writable dirs owned www-data
|
||
|
|
RUN chown -R root:www-data /var/www/html \
|
||
|
|
&& find /var/www/html -type d -exec chmod 755 {} \; \
|
||
|
|
&& find /var/www/html -type f -exec chmod 644 {} \; \
|
||
|
|
&& mkdir -p logs cache public/assets/uploads/avatars \
|
||
|
|
&& chown -R www-data:www-data logs cache public/assets/uploads \
|
||
|
|
&& chmod -R 775 logs cache public/assets/uploads \
|
||
|
|
&& chmod 775 /var/www/html
|
||
|
|
|
||
|
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||
|
|
RUN chmod +x /entrypoint.sh
|
||
|
|
|
||
|
|
EXPOSE 7876
|
||
|
|
|
||
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
||
|
|
CMD ["apache2-foreground"]
|