Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FROM php:8.2-apache
- RUN apt-get update && apt-get install -y \
- git \
- curl \
- libpng-dev \
- libonig-dev \
- libxml2-dev \
- libssl-dev \
- pkg-config \
- zip \
- unzip
- RUN rm -rf /var/lib/apt/lists/*
- RUN docker-php-ext-install pdo_mysql mysqli mbstring exif pcntl bcmath gd intl
- COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
- COPY ./src/ /var/www/html
- WORKDIR /var/www/html
- # Configuration port
- ENV PORT=8080
- RUN echo "Listen \${PORT}" > /etc/apache2/ports.conf
- RUN sed -i 's/:80/:${PORT}/g' /etc/apache2/sites-available/*.conf
- # Configuration ServerName
- RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
- # Ajout d'un fichier de configuration VirtualHost
- RUN echo "<VirtualHost *:\${PORT}> \n\
- DocumentRoot \${APACHE_DOCUMENT_ROOT} \n\
- <Directory \${APACHE_DOCUMENT_ROOT}> \n\
- Options Indexes FollowSymLinks \n\
- AllowOverride All \n\
- Require all granted \n\
- </Directory> \n\
- </VirtualHost>" > /etc/apache2/sites-available/000-default.conf
- # Configuration d'Apache
- ENV APACHE_DOCUMENT_ROOT /var/www/html/public
- RUN sed -ri -e 's#/var/www/html#${APACHE_DOCUMENT_ROOT}#g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
- # Activation du module rewrite d'Apache
- RUN a2enmod rewrite
- # Activer le module remoteip
- RUN a2enmod remoteip
- # Ajouter la config pour gérer les headers de proxy
- RUN echo 'RemoteIPHeader X-Forwarded-For\n\
- RemoteIPInternalProxy 10.0.0.0/8\n\
- RemoteIPInternalProxy 172.16.0.0/12\n\
- SetEnvIf X-Forwarded-Proto "https" HTTPS=on' \
- > /etc/apache2/conf-available/remoteip.conf \
- && a2enconf remoteip
- # Définition du script de démarrage
- COPY docker-entrypoint.sh /usr/local/bin/
- RUN chmod +x /usr/local/bin/docker-entrypoint.sh
- ENTRYPOINT ["/bin/sh", "/usr/local/bin/docker-entrypoint.sh"]
- # Exposer le port attendu par Railway
- EXPOSE 8080
- # Lancer Apache au premier plan
- CMD ["apachectl", "-D", "FOREGROUND"]
Advertisement
Add Comment
Please, Sign In to add comment