From d82194a2b4001414d546438bf8c9ebd65ddd694c Mon Sep 17 00:00:00 2001 From: Jerry Aldrich Date: Tue, 2 Aug 2022 00:20:30 -0700 Subject: [PATCH] Initial commit --- Dockerfile | 22 +++++++++++++++ README.md | 19 +++++++++++++ entrypoint.sh | 37 ++++++++++++++++++++++++++ index.html | 12 +++++++++ lighttpd.conf | 29 ++++++++++++++++++++ mime-types.conf | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 190 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 entrypoint.sh create mode 100644 index.html create mode 100644 lighttpd.conf create mode 100644 mime-types.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b1c2d37 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM alpine:3.15.5 + +EXPOSE 8080 + +LABEL maintainer "me@jerryaldrichiii.com" + +RUN apk add --no-cache lighttpd=1.4.64-r0 + +RUN chown -R lighttpd /var/log/lighttpd + +RUN mkdir -p /etc/lighttpd/conf.d + +USER lighttpd + +COPY lighttpd.conf /etc/lighttpd/lighttpd.conf +COPY mime-types.conf /etc/lighttpd/mime-types.conf + +# Copying as lighttpd so that a user's entrypoint can remove/overwrite it +COPY --chown=lighttpd index.html /srv/html/index.html + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..35074e0 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Lighttpd + +I couldn't find a non-root Lighttpd container, so I made one. + +It runs with UID=100 and GID=101 + +## Serving Static Websites + +Place your files into `/srv/html/` to serve them. + +## Customizing Startup + +Any scripts placed in `/docker-entrypoint.d/` will be executed alphabetically +prior to `entrypoint.sh` + +## Adding extra config + +Any .conf files included into `/etc/lighttpd/conf.d` will be appended to the +included `lighttpd.conf`. diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..ef9d677 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# CREDIT: https://github.com/nginxinc/docker-nginx/blob/f3d86e99ba2db5d9918ede7b094fcad7b9128cd8/mainline/alpine/docker-entrypoint.sh + +set -e + +if [ -n "${LIGHTTPD_QUIET_LOGS:-}" ]; then + exec 3>/dev/null +else + exec 3>&1 +fi + +if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then + echo >&3 "$0: /docker-entrypoint.d/ is not empty, will run .sh files there prior to regular entrypoint" + + echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/" + find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do + case "$f" in + *.sh) + if [ -x "$f" ]; then + echo >&3 "$0: Launching $f"; + "$f" + else + # warn on shell scripts without exec bit + echo >&3 "$0: Ignoring $f, not executable"; + fi + ;; + *) echo >&3 "$0: Ignoring $f";; + esac + done + + echo >&3 "$0: Configuration complete; ready for start up" +else + echo >&3 "$0: No files found in /docker-entrypoint.d/, proceeding to regular entrypoint" +fi + +lighttpd -D -f /etc/lighttpd/lighttpd.conf diff --git a/index.html b/index.html new file mode 100644 index 0000000..552c034 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + + + Content Missing + + + +

This is just a placeholder page.

+

You should mount static content in /srv/html/

+

See README.md for more details

+ + diff --git a/lighttpd.conf b/lighttpd.conf new file mode 100644 index 0000000..8a30e00 --- /dev/null +++ b/lighttpd.conf @@ -0,0 +1,29 @@ +var.logdir = "/var/log/lighttpd" +var.statedir = "/var/lib/lighttpd" + +server.modules = ( + "mod_access", + "mod_accesslog", + "mod_setenv", +) + +accesslog.filename = "/dev/fd/2" + +include "mime-types.conf" + +server.document-root = "/srv/html/" +server.pid-file = "/tmp/lighttpd.pid" + +server.errorlog-use-syslog = "enable" +accesslog.use-syslog = "enable" + +server.indexfiles = ("index.html", "index.htm", "default.htm") + +server.port = 8080 + +url.access-deny = ("~", ".inc") + +server.network-backend = "writev" +server.tag = "If you're reading this you're up to no good..." + +include "/etc/lighttpd/conf.d/*.conf" diff --git a/mime-types.conf b/mime-types.conf new file mode 100644 index 0000000..93ed465 --- /dev/null +++ b/mime-types.conf @@ -0,0 +1,71 @@ +mimetype.assign = ( + ".svg" => "image/svg+xml", + ".svgz" => "image/svg+xml", + ".pdf" => "application/pdf", + ".sig" => "application/pgp-signature", + ".spl" => "application/futuresplash", + ".class" => "application/octet-stream", + ".ps" => "application/postscript", + ".torrent" => "application/x-bittorrent", + ".dvi" => "application/x-dvi", + ".gz" => "application/x-gzip", + ".pac" => "application/x-ns-proxy-autoconfig", + ".swf" => "application/x-shockwave-flash", + ".tar.gz" => "application/x-tgz", + ".tgz" => "application/x-tgz", + ".tar" => "application/x-tar", + ".zip" => "application/zip", + ".dmg" => "application/x-apple-diskimage", + ".mp3" => "audio/mpeg", + ".m3u" => "audio/x-mpegurl", + ".wma" => "audio/x-ms-wma", + ".wax" => "audio/x-ms-wax", + ".ogg" => "application/ogg", + ".wav" => "audio/x-wav", + ".gif" => "image/gif", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".xbm" => "image/x-xbitmap", + ".xpm" => "image/x-xpixmap", + ".xwd" => "image/x-xwindowdump", + ".css" => "text/css", + ".html" => "text/html", + ".htm" => "text/html", + ".js" => "text/javascript", + ".asc" => "text/plain", + ".c" => "text/plain", + ".h" => "text/plain", + ".cc" => "text/plain", + ".cpp" => "text/plain", + ".hh" => "text/plain", + ".hpp" => "text/plain", + ".conf" => "text/plain", + ".log" => "text/plain", + ".text" => "text/plain", + ".txt" => "text/plain", + ".diff" => "text/plain", + ".patch" => "text/plain", + ".ebuild" => "text/plain", + ".eclass" => "text/plain", + ".rtf" => "application/rtf", + ".bmp" => "image/bmp", + ".tif" => "image/tiff", + ".tiff" => "image/tiff", + ".ico" => "image/x-icon", + ".dtd" => "text/xml", + ".xml" => "text/xml", + ".mpeg" => "video/mpeg", + ".mpg" => "video/mpeg", + ".mov" => "video/quicktime", + ".qt" => "video/quicktime", + ".avi" => "video/x-msvideo", + ".asf" => "video/x-ms-asf", + ".asx" => "video/x-ms-asf", + ".wmv" => "video/x-ms-wmv", + ".bz2" => "application/x-bzip", + ".tbz" => "application/x-bzip-compressed-tar", + ".wasm" => "application/wasm", + ".tar.bz2" => "application/x-bzip-compressed-tar" + ) +