Skip to content

Commit edd0552

Browse files
Merge pull request #107 from thylong/feat/12factor-compliant-apache-config
Feat/12factor compliant apache config
2 parents c9666b8 + ccf51b0 commit edd0552

File tree

6 files changed

+823
-108
lines changed

6 files changed

+823
-108
lines changed

Dockerfile

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,24 @@ RUN apk --no-cache --update \
3838
&& mkdir /htdocs
3939

4040
COPY linkstack /htdocs
41+
COPY configs/apache2/httpd.conf /etc/apache2/httpd.conf
42+
COPY configs/apache2/ssl.conf /etc/apache2/conf.d/ssl.conf
43+
COPY configs/php/php.ini /etc/php8.2/php.ini
44+
45+
RUN chown apache:apache /etc/ssl/apache2/server.pem
46+
RUN chown apache:apache /etc/ssl/apache2/server.key
47+
4148
RUN chown -R apache:apache /htdocs
4249
RUN find /htdocs -type d -print0 | xargs -0 chmod 0755
4350
RUN find /htdocs -type f -print0 | xargs -0 chmod 0644
4451

4552
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/
4653

47-
HEALTHCHECK CMD curl -f http://localhost -A "HealthCheck" || exit 1
48-
49-
# Enable compression
50-
RUN sed -i '/LoadModule mime_module/s/^#//g' /etc/apache2/httpd.conf \
51-
&& sed -i '/LoadModule deflate_module/s/^#//g' /etc/apache2/httpd.conf \
52-
&& sed -i '/AddOutputFilterByType text\/html/s/^#//g' /etc/apache2/httpd.conf \
53-
&& sed -i '/AddOutputFilterByType text\/plain/s/^#//g' /etc/apache2/httpd.conf \
54-
&& sed -i '/AddOutputFilterByType text\/xml/s/^#//g' /etc/apache2/httpd.conf \
55-
&& sed -i '/AddOutputFilterByType application\/javascript/s/^#//g' /etc/apache2/httpd.conf \
56-
&& sed -i '/AddOutputFilterByType text\/css/s/^#//g' /etc/apache2/httpd.conf \
57-
&& sed -i '/AddOutputFilterByType image\/svg\+xml/s/^#//g' /etc/apache2/httpd.conf \
58-
&& sed -i '/AddOutputFilterByType application\/x-font-ttf/s/^#//g' /etc/apache2/httpd.conf \
59-
&& sed -i '/AddOutputFilterByType font\/opentype/s/^#//g' /etc/apache2/httpd.conf \
60-
&& sed -i '/AddOutputFilterByType image\/jpeg/s/^#//g' /etc/apache2/httpd.conf \
61-
&& sed -i '/AddOutputFilterByType image\/png/s/^#//g' /etc/apache2/httpd.conf \
62-
&& sed -i '/AddOutputFilterByType image\/gif/s/^#//g' /etc/apache2/httpd.conf
63-
64-
# Forward Apache access and error logs to Docker's log collector.
65-
# Optional last line adds extra verbosity with for example:
66-
# [ssl:info] [pid 33] [client 10.0.5.8:45542] AH01964: Connection to child 2 established (server your.domain:443)
67-
RUN ln -sf /dev/stdout /var/www/logs/access.log \
68-
&& ln -sf /dev/stderr /var/www/logs/error.log \
69-
&& ln -sf /dev/stderr /var/www/logs/ssl-access.log
70-
# && ln -sf /dev/stderr /var/www/logs/ssl-error.log
54+
USER apache:apache
7155

72-
# Enable mod_deflate for text compression
73-
RUN sed -i 's/#LoadModule deflate_module/LoadModule deflate_module/' /etc/apache2/httpd.conf \
74-
&& sed -i 's/#LoadModule filter_module/LoadModule filter_module/' /etc/apache2/httpd.conf \
75-
&& echo 'AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json' >> /etc/apache2/httpd.conf
56+
HEALTHCHECK CMD curl -f http://localhost -A "HealthCheck" || exit 1
7657

7758
# Set console entry path
7859
WORKDIR /htdocs
7960

80-
CMD ["docker-entrypoint.sh"]
61+
CMD ["docker-entrypoint.sh"]

0 commit comments

Comments
 (0)