nginx-dev/Dockerfile

61 lines
3.5 KiB
Docker
Raw Permalink Normal View History

2024-09-08 00:37:19 +02:00
# Usamos Debian 13 como base
FROM docker.io/debian:trixie
# Instalamos systemd, mariadb, php, nginx, etc.
RUN apt-get update && \
apt-get install -y systemd systemd-sysv cron anacron nano wget curl git mariadb-server mariadb-client nginx php-fpm php-common php-gd php-mysql php-imap php-cli php-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php-curl php-intl php-pspell php-sqlite3 php-tidy php-xmlrpc php-xsl memcached php-memcache php-imagick php-zip php-mbstring memcached libapache2-mod-passenger php-soap php-opcache php-apcu libapache2-reload-perl php-mcrypt && \
apt-get clean
# Instalamos phpmyadmin y definimos la contraseña de root de mariadb en blanco para @localhost.
RUN service mariadb start && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -yq install phpmyadmin && \
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD(''); FLUSH PRIVILEGES;" && \
service mariadb stop
# Permitimos el que se pueda loguear sin contraseña para usar el usuario root de ese modo
RUN sed -i "s/ \/\/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/" /etc/phpmyadmin/config.inc.php
# Añadimos las reglas nginx para poder ver phpmyadmin en http://localhost/phpmyadmin
RUN sed -i "s/server_name _;/server_name _;\n\nlocation \/phpmyadmin {\n root \/usr\/share\/;\n index index.php index.html index.htm;\n location ~ \^\/phpmyadmin\/\(.+\.php\)\$ {\n try_files \$uri =404;\n root \/usr\/share\/;\n fastcgi_pass unix:\/var\/run\/php\/php8.2-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$request_filename;\n include \/etc\/nginx\/fastcgi_params;\n fastcgi_param PATH_INFO \$fastcgi_script_name;\n fastcgi_buffer_size 128k;\n fastcgi_buffers 256 4k;\n fastcgi_busy_buffers_size 256k;\n fastcgi_temp_file_write_size 256k;\n fastcgi_intercept_errors on;\n }\n location ~* \^\/phpmyadmin\/\(.+\\.\(jpg\|jpeg\|gif\|css\|png\|js\|ico\|html\|xml\|txt\)\)\$ {\n root \/usr\/share\/;\n }\n}\nlocation \/phpMyAdmin {\n rewrite \^\/* \/phpmyadmin last;\n}/g" /etc/nginx/sites-available/default
# Mostrar los errores en PHP
RUN sed -i 's/display_errors = Off/display_errors = On/' /etc/php/8.2/fpm/php.ini && \
sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/' /etc/php/8.2/fpm/php.ini
# Eliminamos los logs de apt
RUN rm -rf \
/var/lib/apt/lists/* \
/var/log/alternatives.log \
/var/log/apt/history.log \
/var/log/apt/term.log \
/var/log/dpkg.log
# Habilitar servicios
RUN systemctl enable mariadb.service && \
systemctl enable php8.2-fpm.service && \
systemctl enable nginx.service
# Copiamos la configuración para un pool de PHP que corre como root
COPY php-root.conf /etc/php/8.2/fpm/pool.d/root.conf
# Habilitamos que PHP pueda correr como root
RUN sed -i 's/--nodaemonize/--nodaemonize --allow-to-run-as-root/' /usr/lib/systemd/system/php8.2-fpm.service
# Comandos para ejecutar dentro de docker y crear rápido configuraciones de dominios y subdominios
COPY bin/adddomain /usr/local/bin/adddomain
RUN chmod +x /usr/local/bin/adddomain
COPY bin/addsubdomain /usr/local/bin/addsubdomain
RUN chmod +x /usr/local/bin/addsubdomain
# Colocamos dentro el certificado SSL
COPY ssl /etc/nginx/ssl
# Configuración de puertos
EXPOSE 80
EXPOSE 443
# Use systemd as command
CMD [ "/sbin/init" ]