Guest User

Untitled

a guest
Apr 25th, 2025
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. FROM php:8.2-apache
  2.  
  3. RUN apt-get update && apt-get install -y \
  4. git \
  5. curl \
  6. libpng-dev \
  7. libonig-dev \
  8. libxml2-dev \
  9. libssl-dev \
  10. pkg-config \
  11. zip \
  12. unzip
  13. RUN rm -rf /var/lib/apt/lists/*
  14.  
  15. RUN docker-php-ext-install pdo_mysql mysqli mbstring exif pcntl bcmath gd intl
  16.  
  17. COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
  18.  
  19. COPY ./src/ /var/www/html
  20. WORKDIR /var/www/html
  21.  
  22. # Configuration port
  23. ENV PORT=8080
  24. RUN echo "Listen \${PORT}" > /etc/apache2/ports.conf
  25. RUN sed -i 's/:80/:${PORT}/g' /etc/apache2/sites-available/*.conf
  26.  
  27. # Configuration ServerName
  28. RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
  29.  
  30. # Ajout d'un fichier de configuration VirtualHost
  31. RUN echo "<VirtualHost *:\${PORT}> \n\
  32. DocumentRoot \${APACHE_DOCUMENT_ROOT} \n\
  33. <Directory \${APACHE_DOCUMENT_ROOT}> \n\
  34. Options Indexes FollowSymLinks \n\
  35. AllowOverride All \n\
  36. Require all granted \n\
  37. </Directory> \n\
  38. </VirtualHost>" > /etc/apache2/sites-available/000-default.conf
  39.  
  40. # Configuration d'Apache
  41. ENV APACHE_DOCUMENT_ROOT /var/www/html/public
  42. RUN sed -ri -e 's#/var/www/html#${APACHE_DOCUMENT_ROOT}#g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
  43.  
  44. # Activation du module rewrite d'Apache
  45. RUN a2enmod rewrite
  46.  
  47. # Activer le module remoteip
  48. RUN a2enmod remoteip
  49.  
  50. # Ajouter la config pour gérer les headers de proxy
  51. RUN echo 'RemoteIPHeader X-Forwarded-For\n\
  52. RemoteIPInternalProxy 10.0.0.0/8\n\
  53. RemoteIPInternalProxy 172.16.0.0/12\n\
  54. SetEnvIf X-Forwarded-Proto "https" HTTPS=on' \
  55. > /etc/apache2/conf-available/remoteip.conf \
  56. && a2enconf remoteip
  57.  
  58. # Définition du script de démarrage
  59. COPY docker-entrypoint.sh /usr/local/bin/
  60. RUN chmod +x /usr/local/bin/docker-entrypoint.sh
  61. ENTRYPOINT ["/bin/sh", "/usr/local/bin/docker-entrypoint.sh"]
  62.  
  63. # Exposer le port attendu par Railway
  64. EXPOSE 8080
  65.  
  66. # Lancer Apache au premier plan
  67. CMD ["apachectl", "-D", "FOREGROUND"]
Advertisement
Add Comment
Please, Sign In to add comment