diff --git a/storage/image/Dockerfile b/storage/image/Dockerfile new file mode 100644 index 000000000..91a39b44f --- /dev/null +++ b/storage/image/Dockerfile @@ -0,0 +1,30 @@ +# Usa la imagen oficial de Apache +FROM httpd:latest + +# Añade configuración del MPM prefork +# RUN echo "LoadModule mpm_prefork_module modules/mod_mpm_prefork.so" >> /usr/local/apache2/conf/httpd.conf +# RUN echo "LoadModule mpm_worker_module modules/mod_mpm_worker.so" >> /usr/local/apache2/conf/httpd.conf + +# Copia tu archivo de configuración personalizado (si lo tienes) +# COPY ./mi-configuracion-httpd.conf /usr/local/apache2/conf/httpd.conf +COPY ./image.png /usr/local/apache2/htdocs/ +COPY ./image.png /usr/local/apache2/htdocs/welcome.png +COPY ./.htaccess /usr/local/apache2/htdocs/ +RUN { \ + echo 'IncludeOptional conf.d/*.conf'; \ +} >> /usr/local/apache2/conf/httpd.conf \ + && mkdir /usr/local/apache2/conf.d + # Copy .htaccess into DocumentRoot +COPY ./.htaccess /var/www/html/ +# Habilita el módulo mod_rewrite +RUN sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/' /usr/local/apache2/conf/httpd.conf +# RUN sed -i 's/#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so' /usr/local/apache2/conf/httpd.conf +# RUN sed -i 's/#LoadModule mpm_prefork_module/LoadModule mpm_prefork_module/' /usr/local/apache2/conf/httpd.conf +# RUN sed -i 's/#LoadModule mpm_worker_module modules/mod_mpm_worker.so' /usr/local/apache2/conf/httpd.conf +# RUN sed -i 's/#LoadModule mpm_worker_module/LoadModule mpm_worker_module/' /usr/local/apache2/conf/httpd.conf + +# Establece el propietario del directorio del servidor a www-data (usuario de Apache) +RUN chown -R www-data:www-data /usr/local/apache2/htdocs/ + +# Expón el puerto 80 para que sea accesible desde fuera del contenedor +EXPOSE 80 diff --git a/storage/image/mi-configuracion-httpd.conf b/storage/image/mi-configuracion-httpd.conf new file mode 100644 index 000000000..8f2954332 --- /dev/null +++ b/storage/image/mi-configuracion-httpd.conf @@ -0,0 +1,24 @@ +# +# LoadModule mpm_prefork_module modules/mod_mpm_prefork.so +# + + + LoadModule mpm_worker_module modules/mod_mpm_worker.so + + + + + RewriteEngine On + + # Asegúrate de que el módulo crypto esté disponible + RewriteCond %{LA-U:CRYPTO:crypto} ^$ + + # Obtén el nombre del archivo sin la extensión + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.+)\.png$ - [E=FILENAME_NO_EXT:$1] + + # Calcula el hash del nombre del archivo + RewriteCond %{LA-U:CRYPTO:crypto} ^(.+)$ + RewriteRule ^(.+)\.png$ /images/%1.png [L] + diff --git a/storage/image/move.sh b/storage/image/move.sh new file mode 100644 index 000000000..14e288830 --- /dev/null +++ b/storage/image/move.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +for collection in */ ; do + for size in "$collection"*/ ; do + for image in "$size"* ; do + fileName=$(basename "$image") + imageName="${fileName%.*}" + hash=$(echo -n "$imageName" | sha1sum | awk '{print $1}') + path=$(dirname "$image")/${hash:2:2}/${hash:0:2} + mkdir -p $path + mv $image $path/$fileName + ln -s $path/$fileName $fileName + done + done +done diff --git a/storage/image/reestructure.sh b/storage/image/reestructure.sh new file mode 100644 index 000000000..06786bffd --- /dev/null +++ b/storage/image/reestructure.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +for collection in */ ; do + for size in "$collection"*/ ; do + for image in "$size"* ; do + fileName=$(basename "$image") + imageName="${fileName%.*}" + hash=$(echo -n "$imageName" | sha1sum | awk '{print $1}') + mkdir -p $(dirname "$image")/${hash:2:2}/${hash:0:2} + ln -s $image $(dirname "$image")/${hash:2:2}/${hash:0:2}/$fileName + done + done +done