-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (51 loc) · 1.95 KB
/
Dockerfile
File metadata and controls
65 lines (51 loc) · 1.95 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
FROM php:7.2-apache
MAINTAINER Troels Madsen <[email protected]>
# Install system dependencies & tools
RUN apt-get update && apt-get install -y \
openssl \
git \
zip \
unzip \
default-mysql-client \
libapache2-mod-security2 \
&& rm -rf /var/lib/apt/lists/*
# Instal php extenstions & enable mod_rewrite
RUN docker-php-ext-install -j$(nproc) \
pdo_mysql \
opcache
RUN a2enmod rewrite
# Get the OWASP modsecurity package from git
RUN git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git /etc/apache2/modsecurity.d
RUN mv /etc/apache2/modsecurity.d/crs-setup.conf.example /etc/apache2/modsecurity.d/crs-setup.conf
# Setup modsecurity
ADD apache/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf /etc/apache2/modsecurity.d/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
ADD apache/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf /etc/apache2/modsecurity.d/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf
ADD apache/security2.conf /etc/apache2/mods-available/security2.conf
RUN mv /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
RUN sed -i \
-e 's/SecRuleEngine DetectionOnly/SecRuleEngine On/' \
-e 's/SecResponseBodyAccess On/SecResponseBodyAccess Off/' \
/etc/modsecurity/modsecurity.conf
WORKDIR /var/www
# Install composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');"
EXPOSE 80
ADD . /var/www
# Setup Apache
ADD apache/000-default.conf /etc/apache2/sites-available/000-default.conf
ADD apache/prod.htaccess /var/www/public/.htaccess
# Switch your UID to match the one developing
ARG userid=1000
ARG groupid=1000
RUN usermod -u ${userid} www-data
# RUN groupmod -g ${groupid} www-data
# Don't be root
RUN chown -R www-data:www-data /var/www
USER www-data
# Install dependencies
RUN php composer.phar install --no-dev --no-interaction
USER root
# Optimizing Laravel
RUN php artisan config:cache