Go to file
Abhinav Sarkar a1810b664b
Removes the line about static compilation
2019-07-14 11:49:13 +05:30
src Adds security headers in response 2018-08-27 22:31:09 +05:30
.gitignore Intial commit 2018-07-21 09:12:42 +05:30
Dockerfile Upgrades stackage lts and base image 2019-06-22 00:45:41 +05:30
LICENSE Intial commit 2018-07-21 09:12:42 +05:30
README.md Removes the line about static compilation 2019-07-14 11:49:13 +05:30
Setup.hs Intial commit 2018-07-21 09:12:42 +05:30
hastatic.cabal Upgrades stackage lts 2019-01-11 10:58:20 +05:30
package.yaml Updates version and stack LTS 2019-07-12 09:43:01 +05:30
stack.yaml Updates version and stack LTS 2019-07-12 09:43:01 +05:30

README.md

hastatic

Docker Build Status Docker Pulls MicroBadger Size

hastatic is a very small web server for serving static files from a Docker container.

Features

  • A lightweight web server, just 5 MB in size.
  • Built for Docker.
  • Supports HTTPS.
  • Supports custom 404 file.
  • Supports custom index files for URLs ending with "/".
  • Takes care to not serve hidden files.
  • Adds caching headers automatically.
  • Adds security headers automatically.
  • Caches file descriptors and info for better performance.

Usage

Create a Dockerfile for your website, deriving from abhin4v/hastatic:

FROM abhin4v/hastatic:latest

COPY mywebsite /opt/mywebsite
WORKDIR /opt/mywebsite
CMD ["/usr/bin/hastatic"]

Build and run:

$ docker build -t mywebsite .
$ # run with default configs
$ docker run -p 8080:3000 mywebsite
$ # run with custom configs
$ docker run -e PORT=2000 -e NF_FILE=404.html -e IDX_FILE=index.html -p 8080:2000 mywebsite
$ # run with HTTPS support
$ docker run -e TLS_CERT_FILE=certificate.pem -e TLS_KEY_FILE=key.pem -p 443:3000 mywebsite

Configuration

The Docker image supports these environment variable for configuration:

  • PORT: the port to run the web server on, default: 3000
  • NF_FILE: name of the custom 404 file, default: 404.html
  • IDX_FILE: name of the custom index files, default: index.html
  • TLS_CERT_FILE: TLS certification file, optional, required for HTTPS support
  • TLS_KEY_FILE: TLS key file, optional, required for HTTPS support

Internals

hastatic is written in Haskell, just 70 lines of it. It uses the excellent Warp server underneath with the warp-tls package for HTTPS support.