-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
49 lines (37 loc) · 2.01 KB
/
Dockerfile
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
FROM httpd:alpine
MAINTAINER Andreas Lorenzen <[email protected]>
# Remove any files that may be in the public htdocs directory already.
RUN rm -r /usr/local/apache2/htdocs/*
# Install curl, just for healthchecking, without using local cache for the package lists
RUN apk --no-cache add curl
# Enable the rewrite module in apache2.
RUN sed -i \
's/#LoadModule rewrite_module modules\/mod_rewrite.so/LoadModule rewrite_module modules\/mod_rewrite.so/g' \
/usr/local/apache2/conf/httpd.conf
# Append to the published directory, that we want to rewrite any request that is not an actual file
# to the index.html page.
RUN sed -i '/<Directory "\/usr\/local\/apache2\/htdocs">/a### Rewrite rule was written from the Dockerfile when building the image ###\n\
DirectoryIndex index.html\n\
RewriteEngine on\n\
RewriteCond %{REQUEST_FILENAME} -s [OR]\n\
RewriteCond %{REQUEST_FILENAME} -d\n\
RewriteRule ^.*$ - [NC,L]\n\
RewriteRule ^(.*) index.html [NC,L]\n' \
/usr/local/apache2/conf/httpd.conf
# Comment out the default config that handles requests to /.htaccess and /.ht* with a special error message,
# Angular will handle all routing
RUN sed -i '/<Files "\.ht\*">/,/<\/Files>/c# This was commented out from the Dockerfile\n# <Files ".ht*">\n# Require all denied\n# <\/Files>' \
/usr/local/apache2/conf/httpd.conf
# Define a healthcheck that tests the root URL of the site
HEALTHCHECK --interval=5s --timeout=3s CMD curl --fail http://localhost:80/ || exit 1
# TODO: Replace in httpd.conf
# ServerAdmin [email protected]
# #ServerName www.example.com:80
# Copy all the files from the docker build context into the public htdocs of the apache container.
COPY ./ /usr/local/apache2/htdocs/
# Change owner of the publicly available files to root user and daemon group. Httpd threads run as daemon.
RUN chown -R root:daemon \
/usr/local/apache2/htdocs/*
# Ensure that the files can only be read, even by the httpd server.
RUN chmod -R 440 \
/usr/local/apache2/htdocs/*