Implementando Redis + docker-compser

This commit is contained in:
2025-11-09 19:56:35 +00:00
parent e71f627fd1
commit 24f7caa102
2 changed files with 21 additions and 15 deletions

View File

@@ -1,13 +1,10 @@
# Imagem base com PHP 8.1 e Apache
FROM php:8.1-apache FROM php:8.1-apache
# Configura o timezone
ENV TZ=America/Sao_Paulo ENV TZ=America/Sao_Paulo
# Habilita o mod_rewrite do Apache
RUN a2enmod rewrite RUN a2enmod rewrite
# Instala dependências e extensões PHP necessárias # Dependências + extensões PHP + Redis
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
libicu-dev \ libicu-dev \
libzip-dev \ libzip-dev \
@@ -18,32 +15,23 @@ RUN apt-get update && apt-get install -y \
git \ git \
zip \ zip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install intl zip pdo pdo_mysql gd \ && docker-php-ext-install intl zip pdo pdo_mysql gd opcache \
&& pecl install redis && docker-php-ext-enable redis \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Habilita e configura OPcache
RUN docker-php-ext-install opcache
# Arquivo customizado de configuração do PHP com OPcache otimizado
COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini
# Define diretório de trabalho padrão
WORKDIR /var/www/html WORKDIR /var/www/html
# Define ordem dos arquivos index
RUN echo "DirectoryIndex login.php index.php" > /etc/apache2/conf-available/directoryindex.conf \ RUN echo "DirectoryIndex login.php index.php" > /etc/apache2/conf-available/directoryindex.conf \
&& a2enconf directoryindex && a2enconf directoryindex
# Copia e descompacta os arquivos da aplicação
COPY app.zip /var/www/html/ COPY app.zip /var/www/html/
RUN unzip -o app.zip -d /var/www/html && rm app.zip RUN unzip -o app.zip -d /var/www/html && rm app.zip
# Permissões para o Apache
RUN chown -R www-data:www-data /var/www/html RUN chown -R www-data:www-data /var/www/html
# Porta HTTP padrão
EXPOSE 80 EXPOSE 80
# Inicia o Apache no foreground
CMD ["apache2-foreground"] CMD ["apache2-foreground"]

18
docker-compose.yml Normal file
View File

@@ -0,0 +1,18 @@
version: '3.8'
services:
web:
build: .
container_name: php_apache
ports:
- "8080:80"
volumes:
- .:/var/www/html
depends_on:
- redis
redis:
image: redis:alpine
container_name: redis_cache
ports:
- "6379:6379"