Dockerfile 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. FROM httpd:alpine
  2. MAINTAINER You <you@somedomain.com>
  3. COPY $PWD/build/docker/httpd/httpd.conf /usr/local/apache2/conf/httpd.conf
  4. # Install curl, just for healthchecking, without using local cache for the package lists
  5. RUN apk --no-cache add curl
  6. # Define a healthcheck that tests the root URL of the site
  7. HEALTHCHECK --interval=5s --timeout=3s CMD curl --fail http://localhost:80/ || exit 1
  8. # Remove any files that may be in the public htdocs directory already.
  9. RUN rm -r /usr/local/apache2/htdocs/*
  10. # Enable the rewrite module in apache2.
  11. RUN sed -i \
  12. 's/#LoadModule rewrite_module modules\/mod_rewrite.so/LoadModule rewrite_module modules\/mod_rewrite.so/g' \
  13. /usr/local/apache2/conf/httpd.conf
  14. # RUN sed -i \
  15. # -e 's/^#\(Include .*httpd-ssl.conf\)/\1/' \
  16. # -e 's/^#\(LoadModule .*mod_ssl.so\)/\1/' \
  17. # -e 's/^#\(LoadModule .*mod_socache_shmcb.so\)/\1/' \
  18. # /usr/local/apache2/conf/httpd.conf
  19. # Append to the published directory, that we want to rewrite any request that is not an actual file
  20. # to the index.html page.
  21. RUN sed -i '/<Directory "\/usr\/local\/apache2\/htdocs">/a### Rewrite rule was written from the Dockerfile when building the image ###\n\
  22. DirectoryIndex index.html\n\
  23. RewriteEngine on\n\
  24. RewriteCond %{REQUEST_FILENAME} -s [OR]\n\
  25. RewriteCond %{REQUEST_FILENAME} -d\n\
  26. RewriteRule ^.*$ - [NC,L]\n\
  27. RewriteRule ^(.*) index.html [NC,L]\n' \
  28. /usr/local/apache2/conf/httpd.conf
  29. # Comment out the default config that handles requests to /.htaccess and /.ht* with a special error message,
  30. # Angular will handle all routing
  31. RUN sed -i '/<Files "\.ht\*">/,/<\/Files>/c# This was commented out from the Dockerfile\n# <Files ".ht*">\n# Require all denied\n# <\/Files>' \
  32. /usr/local/apache2/conf/httpd.conf
  33. # Copy all the files from the docker build context into the public htdocs of the apache container.
  34. # COPY ./ /usr/local/apache2/htdocs/
  35. COPY $PWD/angular-client/dist/fatboar /usr/local/apache2/htdocs/
  36. # Change owner of the publicly available files to root user and daemon group. Httpd threads run as daemon dist/fatboar .
  37. RUN chown -R root:daemon \
  38. /usr/local/apache2/htdocs/*
  39. # Ensure that the files can only be read, even by the httpd server.
  40. RUN chmod -R 440 \
  41. /usr/local/apache2/htdocs/*
  42. # Ensure for all the directories created, that the files within them can be read. We need the
  43. # execution access privilege on the directory for this. Dynamically apply this to all directories
  44. # at least one level into the served root. (-mindepth 1, otherwise the served directory itself
  45. # would be included - no need for that.
  46. RUN find /usr/local/apache2/htdocs/ -mindepth 1 -type d -exec chmod +x {} \;
  47. #RUN mkdir -p /usr/local/apache2/conf/sites/
  48. EXPOSE 80
  49. CMD ["httpd", "-D", "FOREGROUND"]