Browse Source

dockerfile mas rapido

main
Taller FCyT 2 months ago
parent
commit
be00a09326
  1. 91
      Dockerfile

91
Dockerfile

@ -1,78 +1,55 @@
FROM php:7.4-apache FROM php:7.4-apache
# Instalar dependencias del sistema RUN apt-get update && apt-get install -y --no-install-recommends \
RUN apt-get update && apt-get install -y \ $PHPIZE_DEPS \
libpq-dev \ libpq-dev libicu-dev libzip-dev zlib1g-dev libonig-dev \
libicu-dev \ libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
libzip-dev \ libcurl4-openssl-dev \
libonig-dev \ git unzip curl ca-certificates \
libfreetype6-dev \ && rm -rf /var/lib/apt/lists/*
libjpeg62-turbo-dev \
libpng-dev \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Instalar extensiones PHP requeridas
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \ && docker-php-ext-install -j"$(nproc)" \
pdo_pgsql \ pdo_pgsql mbstring curl gd intl zip
mbstring \
curl \
openssl \
apcu \
gd \
intl \
zip
# Configurar PHP RUN pecl install apcu \
RUN echo "max_input_vars = 2000" >> /usr/local/etc/php/conf.d/custom.ini \ && docker-php-ext-enable apcu \
&& echo "allow_url_fopen = On" >> /usr/local/etc/php/conf.d/custom.ini \ && apt-get purge -y --auto-remove $PHPIZE_DEPS || true
&& echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "upload_max_filesize = 50M" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/custom.ini
# Instalar Composer RUN { \
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer echo "max_input_vars = 2000"; \
echo "allow_url_fopen = On"; \
echo "memory_limit = 512M"; \
echo "upload_max_filesize = 50M"; \
echo "post_max_size = 50M"; \
} > /usr/local/etc/php/conf.d/custom.ini
# Instalar yui-compressor COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN curl -L -o yuicompressor-2.4.8.jar https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.jar \
&& mv yuicompressor-2.4.8.jar /usr/local/bin/yuicompressor.jar
# Configurar Apache RUN curl -L -o /usr/local/bin/yuicompressor.jar \
RUN a2enmod rewrite \ https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.jar
&& a2enmod headers \
&& a2enmod ssl RUN a2enmod rewrite headers ssl
# Crear directorio de trabajo
WORKDIR /var/www/html WORKDIR /var/www/html
# Copiar archivos del proyecto # Copiar código directamente con dueño correcto
COPY . /var/www/html/ COPY --chown=www-data:www-data . /var/www/html/
# Instalar dependencias de Composer RUN composer install --prefer-dist --no-dev --optimize-autoloader || true
RUN composer install --prefer-dist --no-dev --optimize-autoloader
# Configurar permisos # Crear solo carpetas necesarias con permisos
RUN chown -R www-data:www-data /var/www/html \ RUN mkdir -p /var/www/html/instalacion/{temp,log,cache} \
&& chmod -R 755 /var/www/html \ && chown -R www-data:www-data /var/www/html/instalacion/{temp,log,cache} \
&& mkdir -p /var/www/html/instalacion/temp \ && chmod -R 777 /var/www/html/instalacion/{temp,log,cache}
&& mkdir -p /var/www/html/instalacion/log \
&& mkdir -p /var/www/html/instalacion/cache \
&& chown -R www-data:www-data /var/www/html/instalacion/temp \
&& chown -R www-data:www-data /var/www/html/instalacion/log \
&& chown -R www-data:www-data /var/www/html/instalacion/cache \
&& chmod -R 777 /var/www/html/instalacion/temp \
&& chmod -R 777 /var/www/html/instalacion/log \
&& chmod -R 777 /var/www/html/instalacion/cache
# Configurar Apache para el proyecto
COPY docker/apache-config.conf /etc/apache2/sites-available/000-default.conf COPY docker/apache-config.conf /etc/apache2/sites-available/000-default.conf
# Script de inicialización # Copiar rewrite.conf (asegurar ruta correcta)
COPY instalacion/rewrite.conf /var/www/html/instalacion/rewrite.conf
COPY docker/init.sh /usr/local/bin/init.sh COPY docker/init.sh /usr/local/bin/init.sh
RUN chmod +x /usr/local/bin/init.sh RUN chmod +x /usr/local/bin/init.sh
EXPOSE 80 EXPOSE 80
CMD ["/usr/local/bin/init.sh"] CMD ["/usr/local/bin/init.sh"]

Loading…
Cancel
Save