-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (50 loc) · 3.13 KB
/
Dockerfile
File metadata and controls
65 lines (50 loc) · 3.13 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
## Set our base image ##
FROM php:8-apache
## Install Required Packages ##
RUN apt-get update && apt-get install -y --no-install-recommends wget nano vim git tar gnupg lsb-release automake libtool autoconf unzip jq
## Copy Configs and Scripts ##
COPY ./configs/99modsecurity /etc/apt/preferences.d/99modsecurity
COPY ./scripts/config_gpg.sh /usr/local/bin/config_gpg
COPY ./scripts/cli_log.sh /usr/local/bin/cli_log
## Make Scripts Executable ##
RUN chmod +x /usr/local/bin/config_gpg /usr/local/bin/cli_log
## Configure gpg keys ##
RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg
RUN mkdir -p /etc/apt/keyrings && install -m 0755 -d /etc/apt/keyrings
## Install gpg keys ##
RUN config_gpg https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key nodesource
RUN config_gpg https://modsecurity.digitalwave.hu/archive.key modsecurity
RUN config_gpg https://www.aptly.info/pubkey.txt aptly
## Setup Repos and apt pinning ##
RUN echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" | tee /etc/apt/sources.list.d/node.list
RUN echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/modsecurity.gpg] http://modsecurity.digitalwave.hu/debian/ $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/dwmodsec.list
RUN echo "deb [signed-by=/etc/apt/keyrings/aptly.gpg] http://repo.aptly.info/ci $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/aptly.list
## Install PHP Extension Installer ##
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions
## Install Packages and Extensions ##
RUN apt-get update && apt-get install -y --no-install-recommends aptly nodejs libapache2-mod-security2
RUN install-php-extensions bcmath exif gd gettext imagick intl mysqli opcache pdo_mysql redis zip
## Symlink and update for Node ##
RUN ln -s /usr/bin/node /usr/local/bin/node
RUN npm install npm@latest -g
## Setup Modsecurity ##
# https://www.linuxcapable.com/how-to-install-modsecurity-with-apache-on-ubuntu-linux
# https://modsecurity.digitalwave.hu
# https://coreruleset.org/docs/deployment/install
RUN cp /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
RUN sed -i 's/SecRuleEngine DetectionOnly/SecRuleEngine On/' /etc/modsecurity/modsecurity.conf
RUN sed -i 's/SecAuditLogParts ABDEFHIJZ/SecAuditLogParts ABCEFHJKZ/' /etc/modsecurity/modsecurity.conf
## Install OWASP Core Rule Set ##
RUN git clone https://github.com/coreruleset/coreruleset /etc/apache2/modsecurity.d/coreruleset
RUN cp /etc/apache2/modsecurity.d/coreruleset/crs-setup.conf.example /etc/apache2/modsecurity.d/coreruleset/crs-setup.conf
COPY configs/modsec_rules.conf /etc/apache2/conf-enabled
## MaxMind DB ##
#RUN git clone https://github.com/maxmind/mod_maxminddb /root/mod_maxminddb
#RUN cd /root/mod_maxminddb && ./bootstrap && ./configure && make install
## Enable Modules ##
RUN a2enmod rewrite security2 headers
## COPY Composer ##
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
## Cleanup ##
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*