-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
90 lines (78 loc) · 2.9 KB
/
Copy pathDockerfile
File metadata and controls
90 lines (78 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Image de base - Apache avec PHP 7.4
FROM php:7.4-apache
# Métadonnées
LABEL maintainer="CYBERTECH SERVICES"
LABEL description="Secure Internal Web Service - CYBERTECH"
LABEL version="1.0"
# Installation des extensions PHP nécessaires
RUN docker-php-ext-install pdo pdo_mysql mysqli
# Installation des outils utiles
RUN apt-get update && apt-get install -y \
curl \
vim \
&& rm -rf /var/lib/apt/lists/*
# Activation des modules Apache nécessaires
RUN a2enmod rewrite headers
# Configuration PHP pour la sécurité
RUN { \
echo 'display_errors = Off'; \
echo 'log_errors = On'; \
echo 'error_log = /var/log/apache2/php_errors.log'; \
echo 'expose_php = Off'; \
echo 'session.cookie_httponly = 1'; \
echo 'session.cookie_secure = 0'; \
echo 'session.use_strict_mode = 1'; \
echo 'session.use_only_cookies = 1'; \
echo 'upload_max_filesize = 5M'; \
echo 'post_max_size = 5M'; \
echo 'max_execution_time = 30'; \
echo 'memory_limit = 128M'; \
} > /usr/local/etc/php/conf.d/security.ini
# Configuration Apache
RUN { \
echo '<VirtualHost *:80>'; \
echo ' ServerAdmin admin@cybertech.local'; \
echo ' DocumentRoot /var/www/html'; \
echo ' '; \
echo ' <Directory /var/www/html>'; \
echo ' Options -Indexes +FollowSymLinks'; \
echo ' AllowOverride All'; \
echo ' Require all granted'; \
echo ' </Directory>'; \
echo ' '; \
echo ' <Directory /var/www/html/includes>'; \
echo ' Require all denied'; \
echo ' </Directory>'; \
echo ' '; \
echo ' <Directory /var/www/html/database>'; \
echo ' Require all denied'; \
echo ' </Directory>'; \
echo ' '; \
echo ' ErrorLog ${APACHE_LOG_DIR}/error.log'; \
echo ' CustomLog ${APACHE_LOG_DIR}/access.log combined'; \
echo ' '; \
echo ' # Security Headers'; \
echo ' Header always set X-Frame-Options "SAMEORIGIN"'; \
echo ' Header always set X-Content-Type-Options "nosniff"'; \
echo ' Header always set X-XSS-Protection "1; mode=block"'; \
echo ' Header always set Referrer-Policy "strict-origin-when-cross-origin"'; \
echo ' Header unset Server'; \
echo ' Header unset X-Powered-By'; \
echo '</VirtualHost>'; \
} > /etc/apache2/sites-available/000-default.conf
# Copier les fichiers de l'application
COPY src/ /var/www/html/
# Définir les permissions correctes
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html \
&& chmod 750 /var/www/html/includes \
&& chmod 640 /var/www/html/includes/config.php
# Créer le répertoire des logs
RUN mkdir -p /var/log/php && chown www-data:www-data /var/log/php
# Exposer le port 80
EXPOSE 80
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost/ || exit 1
# Démarrer Apache
CMD ["apache2-foreground"]