Amélioration de la structure du projet et démarrage de Docker OK

This commit is contained in:
2022-04-07 13:07:00 +02:00
parent 5c116e15b1
commit 8ac12f715c
14 changed files with 415 additions and 180 deletions

View File

@ -1,59 +1,38 @@
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
# Uncomment the following line to force Apache to pass the Authorization
# header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
#
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
ServerAdmin webmaster@localhost
DocumentRoot /loginapp/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
LogLevel info
ErrorLog |/bin/cat
CustomLog |/bin/cat combined
Header merge Access-Control-Allow-Origin "*"
Header merge Access-Control-Allow-Headers "X-Requested-With"
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
#Alias /page/image /portal/app/uploads/portal_images
Alias /build /loginapp/public/build
Alias /images /loginapp/public/images
#Alias /img /loginapp/public/img
Alias /js /loginapp/public/js
Alias /css /loginapp/public/css
Alias /bundles /loginapp/public/bundles
Alias /favicon.ico /loginapp/public/favicon.ico
Alias /logiinapp /loginapp/public
<Directory "/loginapp/public">
Header merge Access-Control-Allow-Origin "*"
DirectoryIndex app_docker.php
Require all granted
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_docker.php [QSA,L]
</IfModule>
</Directory>
#<Directory "/portal/app/uploads">
# Require all granted
#</Directory>
<FilesMatch "\.(png|jp?g|gif|ico|css|map|woff?|eot|svg|ttf|js|json|pdf)">
ExpiresActive on
ExpiresDefault "access plus 1 weeks"
# For Apache 2.4.9 or higher
# Using SetHandler avoids issues with using ProxyPassMatch in combination
# with mod_rewrite or mod_autoindex
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://127.0.0.1:9000"
# for Unix sockets, Apache 2.4.10 or higher
# SetHandler proxy:unix:/path/to/fpm.sock|fcgi://dummy
</FilesMatch>
# If you use Apache version below 2.4.9 you must consider update or use this instead
# ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
# If you run your Symfony application on a subpath of your document root, the
# regular expression must be changed accordingly:
# ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
DocumentRoot /loginapp/public
<Directory /loginapp/public>
# enable the .htaccess rewrites
AllowOverride All
Require all granted
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

View File

@ -7,7 +7,7 @@ ARG https_proxy=
ENV WAITFORIT_VERSION="v2.4.1"
ARG PHP_VERSION="8.1"
ARG PHP_VERSION="7.4"
ENV PHP_VERSION $PHP_VERSION
RUN export DEBIAN_FRONTEND=noninteractive && \
@ -50,34 +50,32 @@ VOLUME /loginapp/var/logs
VOLUME /loginapp/var/cache
# Install composer
COPY install-composer.sh /root/install-composer.sh
RUN chmod +x /root/install-composer.sh &&\
/root/install-composer.sh &&\
rm -f /root/install-composer.sh
COPY install-composer.sh /loginapp/install-composer.sh
RUN chmod +x /loginapp/install-composer.sh &&\
/loginapp/install-composer.sh &&\
rm -f /loginapp/install-composer.sh
# On active les mods d'apache nécessaires
RUN a2enmod rewrite
RUN a2enmod proxy_fcgi setenvif
RUN a2enconf php8.1-fpm
RUN a2enconf php7.4-fpm
RUN a2enmod proxy
RUN a2enmod expires
RUN a2enmod headers
# On injecte les bonnes configs apache et php-fpm
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
COPY www.conf /etc/php/8.1/fpm/pool.d/www.conf
# Allow passing of environment variables to PHP
# Used in web/app_dev.php to detect docker-compose environment
RUN for i in /etc/php/*; do mkdir -p $i/cli/conf.d; echo 'variables_order = "EGPCS"' > $i/cli/conf.d/mse.ini; done;
COPY www.conf /etc/php/7.4/fpm/pool.d/www.conf
EXPOSE 5000
EXPOSE 80
WORKDIR /loginapp
# Flag to allow access to app_dev.php from Docker host
ENV MSE_DOCKER_COMPOSER_DEVELOPMENT=yes
# On démarre php-fpm une fois pour créer les sockets
RUN service php7.4-fpm start
RUN service php7.4-fpm stop
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
@ -85,9 +83,6 @@ RUN chmod +x /docker-entrypoint.sh
COPY first-run.sh /root/first-run.sh
RUN chmod +x /root/first-run.sh
# On crée un point d'entrée non restrictif et non tracké pour être utilisé par apache
COPY app_docker.php /root/app_docker.php
# Disable rsyslog privileges drop to allow stdout logging
RUN sed -i 's/^\$\(PrivDropTo.*\)$/#\1/' /etc/rsyslog.conf
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf

View File

@ -1,17 +0,0 @@
<?php
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../vendor/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', true);
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
}
Request::setTrustedProxies(['192.168.0.0/24'], Request::HEADER_X_FORWARDED_ALL);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

View File

@ -2,9 +2,6 @@
set -xeo pipefail
sudo cp /root/app_docker.php /loginapp/public/app_docker.php
[ ! -d /var/www/.config ] && sudo mkdir -p /var/www/.config
[ -d /var/www/.config ] && sudo chown -R www-data: /var/www/.config

View File

@ -13,7 +13,7 @@ then
exit 1
fi
php composer-setup.php
php composer-setup.php --install-dir=bin
RESULT=$?
rm composer-setup.php
exit $RESULT

View File

@ -15,7 +15,7 @@ stderr_logfile_maxbytes=0
[program:apache2]
environment=HOSTNAME="%(ENV_HOSTNAME)s"
command = apachectl -D "FOREGROUND" -k start
command = apachectl -D "FOREGROUND"
directory = /loginapp
user = root
autostart = true
@ -26,7 +26,7 @@ stderr_logfile_maxbytes=0
[program:php-fpm]
environment=HOSTNAME="%(ENV_HOSTNAME)s"
command = /usr/sbin/php-fpm8.1 -F -R
command = /usr/sbin/php-fpm7.4 -F
autostart = true
autorestart = true
directory = /loginapp

View File

@ -3,12 +3,10 @@ daemonize=no
error_log=/dev/stderr
[www]
user = www-data
group = www-data
listen = /run/php/php8.1-fpm.sock
listen.allowed_clients = 127.0.0.1
listen = /run/php/php7.4-fpm.sock
listen.owner = www-data
listen.group = www-data
@ -19,4 +17,4 @@ pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
catch_workers_output = yes
catch_workers_output = yes