@@ -3,10 +3,11 @@ FROM centos:7
33MAINTAINER dan78uk
44
55# Install required dependencies
6- RUN yum -y groups mark convert
7- RUN yum clean all && yum -y swap fakesystemd systemd
8- RUN yum -y groupinstall 'Development Tools' && yum -y clean all
9- RUN yum -y install gcc-c++ pcre-dev pcre-devel zlib-devel make unzip httpd-devel libxml2 libxml2-devel wget openssl-devel && yum -y clean all
6+ RUN yum -y groups mark convert \
7+ && yum clean all && yum -y swap fakesystemd systemd \
8+ && yum -y groupinstall 'Development Tools' && yum -y clean all \
9+ && yum -y install gcc-c++ pcre-dev pcre-devel zlib-devel make unzip httpd-devel libxml2 libxml2-devel wget openssl-devel \
10+ && yum -y clean all
1011
1112# Set working dir
1213ENV WORKING_DIRECTORY=/opt/nginx_mod_security
@@ -41,31 +42,34 @@ RUN wget https://raw.githubusercontent.com/SpiderLabs/ModSecurity/master/modsecu
4142 && cat ${CRS_DIR}/modsecurity_crs_10_setup.conf.example >> /etc/nginx/modsecurity.conf \
4243 && cat ${CRS_DIR}/base_rules/modsecurity_*.conf >> /etc/nginx/modsecurity.conf \
4344 && cp ${CRS_DIR}/base_rules/*.data /etc/nginx/ \
44- && cp ModSecurity/unicode.mapping /etc/nginx/unicode.mapping
45+ && cp ModSecurity/unicode.mapping /etc/nginx/unicode.mapping \
46+ && rm -rf ${CRS_DIR} *.tar.gz
4547
4648# Compile Nginx
4749RUN wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
4850 && tar -xvzf nginx-${NGINX_VERSION}.tar.gz \
4951 && cd nginx-${NGINX_VERSION}/ \
5052 && ./configure $NGINX_ADD_MODULES $NGINX_EXTRA_MODULES \
5153 && make \
52- && make install
54+ && make install \
55+ && cd .. \
56+ && rm -rf nginx-${NGINX_VERSION} nginx-${NGINX_VERSION}.tar.gz
5357
5458# Link nginx and clean solution
55- RUN ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
56- RUN cp /usr/local/nginx/conf/*.* /etc/nginx/
59+ RUN ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx \
60+ && cp /usr/local/nginx/conf/*.* /etc/nginx/
5761WORKDIR /etc/nginx
58- RUN rm -rf $WORKING_DIRECTORY
59- RUN yum -y groupremove "Development tools"
60- RUN yum -y clean headers
61- RUN yum -y clean packages
62+ RUN rm -rf $WORKING_DIRECTORY \
63+ && yum -y groupremove "Development tools" \
64+ && yum clean all
6265
6366# Check Nginx installation
6467RUN nginx -V
6568
6669# Enable basic configurations and import of external configurations
67- RUN yum -y install openssl && yum -y clean all
68- RUN rm -rf /etc/nginx/conf.d/*; \
70+ RUN yum -y install openssl \
71+ && yum -y clean all \
72+ && rm -rf /etc/nginx/conf.d/*; \
6973 mkdir -p /etc/nginx/external
7074RUN sed -i 's/access_log.*/access_log \/ dev\/ stdout;/g' /etc/nginx/nginx.conf; \
7175 sed -i 's/error_log.*/error_log \/ dev\/ stdout info;/g' /etc/nginx/nginx.conf;
0 commit comments