Dockerfile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. FROM alpine:latest
  2. RUN \
  3. apk add --upgrade --update-cache lighttpd lighttpd-mod_webdav curl && \
  4. mkdir -p /var/www/html && \
  5. \
  6. echo "Generating content..." && \
  7. \
  8. # add images
  9. for i in 0 1 2 3 4 5 6 7 8 9; do \
  10. curl -sL -o "/var/www/html/$i.jpg" "https://picsum.photos/1280/960"; \
  11. echo "Added $i.jpg."; \
  12. done && \
  13. \
  14. # add transparent png
  15. curl -s -o /var/www/html/transparent-test.png "https://www.w3.org/Graphics/PNG/alphatest.png" && \
  16. echo "Added transparent-test.png." && \
  17. \
  18. # add fonts
  19. for font in notoserif/NotoSerif-Regular.ttf unlock/Unlock-Regular.ttf blackandwhitepicture/BlackAndWhitePicture-Regular.ttf indieflower/IndieFlower-Regular.ttf; do \
  20. curl -s -o "/var/www/html/$(basename $font)" "https://cdn.jsdelivr.net/gh/google/fonts/ofl/$font"; \
  21. echo "Added $font."; \
  22. done && \
  23. \
  24. # add video
  25. curl -s -o /var/www/html/video.mp4 "http://techslides.com/demos/sample-videos/small.mp4" && \
  26. echo "Added small.mp4." && \
  27. \
  28. # add PDF
  29. curl -s -o /var/www/html/dummy.pdf "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" && \
  30. echo "Added dummy.pdf." && \
  31. \
  32. # set ownership properly
  33. chown -R lighttpd:lighttpd /var/www && \
  34. \
  35. # create some inaccessible files for testing
  36. mkdir -p /var/www/html/inaccessible-dir && \
  37. curl -sL -o "/var/www/html/inaccessible-image.jpg" "https://picsum.photos/1280/960" && \
  38. echo 'Lorem upsum dolor sit amet' > /var/www/html/inaccessible-text-file.txt && \
  39. > /var/www/html/inaccessible-file && \
  40. chmod 700 /var/www/html/inaccessible* && \
  41. \
  42. mkdir -p /var/run/lighttpd && \
  43. chown lighttpd:lighttpd /var/run/lighttpd && \
  44. chmod a+w /dev/stderr && \
  45. \
  46. sed -i -e 's/# "mod_webdav",/ "mod_webdav",/' /etc/lighttpd/lighttpd.conf && \
  47. sed -i -e 's/# "mod_alias",/ "mod_alias",/' /etc/lighttpd/lighttpd.conf && \
  48. sed -i -e 's!server.document-root = var.basedir + "/htdocs"!server.document-root = "/var/www/html"!' /etc/lighttpd/lighttpd.conf && \
  49. \
  50. echo >> /etc/lighttpd/lighttpd.conf && \
  51. echo 'alias.url = ( "/webdav-js" => "/var/www/webdav-js" )' >> /etc/lighttpd/lighttpd.conf && \
  52. echo 'webdav.activate = "enable"' >> /etc/lighttpd/lighttpd.conf && \
  53. echo 'webdav.is-readonly = "disable"' >> /etc/lighttpd/lighttpd.conf && \
  54. echo 'dir-listing.activate = "enable"' >> /etc/lighttpd/lighttpd.conf && \
  55. echo 'dir-listing.external-css = "/webdav-js/assets/css/style-min.css"' >> /etc/lighttpd/lighttpd.conf && \
  56. echo 'dir-listing.external-js = "/webdav-js/src/webdav-min.js"' >> /etc/lighttpd/lighttpd.conf && \
  57. echo 'dir-listing.encoding = "utf-8"' >> /etc/lighttpd/lighttpd.conf && \
  58. echo 'webdav.sqlite-db-name = "/var/run/lighttpd/lighttpd.webdav_lock.db"' >> /etc/lighttpd/lighttpd.conf && \
  59. \
  60. # clean up
  61. apk del curl;
  62. EXPOSE 80
  63. CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]