Skip to content

A simple lighttpd image that doesn't use an entrypoint script.

License

Notifications You must be signed in to change notification settings

PDOK/lighttpd-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lighttpd-docker

GitHub license GitHub release Lint Dockerfile Docker Pulls

A simple lighttpd image that doesn't use an entrypoint script.

TL;DR

docker build -t pdok/lighttpd .
docker run --rm -d -v `pwd`/www/:/var/www -p 80:80 --name lighttpd-example pdok/lighttpd
docker stop lighttpd-example

Introduction

This project aims to fulfill the need in creating a lighttpd container that is deployable on a scalable infrastructure, like Kubernetes. This means that this image is based on a lightweight base-image.

The image comes with a default, overridable lighttdp.conf file that is specifically aimed at serving static files for a web application. The default configuration comes with:

  • mod_expire: Sets Cache-Control headers on files with hashed filenames like index.561ecd9f.css
  • mod_deflate: Output compression on html, text, css, javascript and xml files, the compressed files are stored in a cache directory

When running this image on Kubernetes and serving out very large files that will be compressed, ensure that the cache directory has it's own volume mount. For most webapps this will not be necessary.

What will it do

It will start a small container containing lighttpd.

Usage

Build

docker build -t pdok/lighttpd .

Enable Dockerfile linting pre-commit hook

Run the following from the root of the repository to enable Dockerfile linting with hadolint:

git config --local include.path ../.gitconfig

Successful Dockerfile linting is a requirement for merging pull requests into master, which is enforced with the Dockerfile Lint Github action.

Run

This image can be run straight from the commandline. Both the default configuration file and the default asset directory can be overridden from the commandline:

  • override default configuration file by mounting a directory with a lighttpd.conf file at /srv/lighttpd in the container
  • override default asset directory by mounting a directory with assets to serve at /var/www in the container
docker run --rm -p 80:80 --name lighttpd-example -v `pwd`/config:/srv/lighttpd -v `pwd`/www:/var/www pdok/lighttpd

Running the example above will create a service on the url http://localhost/

The environment variables that can be set are the following:

  • DEBUG
  • MIN_PROCS
  • MAX_PROCS
  • MAX_LOAD_PER_PROC
  • IDLE_TIMEOUT

The environment variables have a default value set in the Dockerfile.

Use image in another Docker image

See below example for how to use this image to build another image to serve out static files:

work_dir="/tmp/$(uuidgen)"
mkdir "$work_dir"
cd "$work_dir"
echo "<h1>TEST</h1>" > index.html

cat > Dockerfile << EOF
FROM pdok/lighttpd
COPY index.html /var/www/index.html
EOF

docker build -t pdok/lighttpd-test .
docker run -p 80:80 pdok/lighttpd-test

Misc

How to Contribute

Make a pull request...

Contact

Contacting the maintainers can be done through the issue tracker.