Atualizar Dockerfile

This commit is contained in:
2025-11-07 17:19:00 +00:00
parent 0f3be2cb7f
commit 1ef9c24778

View File

@@ -1,58 +1,46 @@
# Dockerfile para aplicação PHP - Deploy no Coolify # Imagem base com PHP 8.1 e Apache
FROM php:8.1-apache FROM php:8.1-apache
# Definir variáveis de ambiente # Configura o timezone
ENV APACHE_DOCUMENT_ROOT=/var/www/html \ ENV TZ=America/Sao_Paulo
PHP_TIMEZONE=America/Sao_Paulo
# Instalar dependências do sistema e extensões PHP necessárias # Habilita o mod_rewrite do Apache
RUN a2enmod rewrite
# Instala dependências e extensões PHP necessárias
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
libpng-dev \ libicu-dev \
libjpeg-dev \
libfreetype6-dev \
libzip-dev \ libzip-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
unzip \ unzip \
git \
zip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \ && docker-php-ext-install intl zip pdo pdo_mysql gd \
pdo_mysql \
mbstring \
gd \
zip \
opcache \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Habilitar mod_rewrite e ajustar diretórios do Apache # Define diretório de trabalho padrão
RUN a2enmod rewrite \ WORKDIR /var/www/html
&& 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
# Copiar e descompactar app.zip no diretório raiz do Apache # Define ordem dos arquivos index
COPY app.zip /tmp/app.zip RUN echo "DirectoryIndex login.php index.php" > /etc/apache2/conf-available/directoryindex.conf \
RUN unzip -q /tmp/app.zip -d ${APACHE_DOCUMENT_ROOT}/ \ && a2enconf directoryindex
&& rm /tmp/app.zip \
&& chown -R www-data:www-data ${APACHE_DOCUMENT_ROOT} \
&& chmod -R 755 ${APACHE_DOCUMENT_ROOT}
# Configurar PHP.ini com otimizações de produção # Copia e descompacta os arquivos da aplicação
RUN echo "[PHP] \n\ COPY app.zip /var/www/html/
memory_limit = 256M \n\ RUN unzip -o app.zip -d /var/www/html && rm app.zip
upload_max_filesize = 50M \n\
post_max_size = 50M \n\
max_execution_time = 300 \n\
max_input_time = 300 \n\
date.timezone = ${PHP_TIMEZONE} \n\
\n\
[opcache] \n\
opcache.enable = 1 \n\
opcache.memory_consumption = 128 \n\
opcache.interned_strings_buffer = 8 \n\
opcache.max_accelerated_files = 10000 \n\
opcache.revalidate_freq = 2 \n\
opcache.fast_shutdown = 1" > /usr/local/etc/php/conf.d/custom.ini
# Expor porta padrão HTTP # Substitui o diretório /files por um link simbólico (volume externo opcional)
# RUN rm -rf /var/www/html/files && ln -s /files /var/www/html/files
# Permissões para o Apache
RUN chown -R www-data:www-data /var/www/html
# Porta HTTP padrão
EXPOSE 80 EXPOSE 80
# Comando padrão para iniciar o Apache # Inicia o Apache no foreground
CMD ["apache2-foreground"] CMD ["apache2-foreground"]