costela/atto

By costela

Updated almost 5 years ago

10⁻¹⁸ × webserver

Image
0

1.4K

Go Report CardDocker Hub Version

atto - 10⁻¹⁸ × webserver

atto is a really, really, really small webserver for static files. Barely more than go's standard http.FileServer.

Usage

The easiest way to use it is by creating your own image based on the costela/atto image:

FROM costela/atto
COPY /path_to_my_staticfile_dir/ /www/

Integrate this into your CD pipeline and deploy it on e.g. kubernetes, behind a reverse proxy (e.g. traefik).

Features

Basically none, but it can and will gladly serve static files. It does not (and will not) support SSL, vHosts, aliases or any of the more advanced features of full-fledged webservers.

Nevertheless, it does have the basics:

  • optional directory listing (inherited from http.FileServer; see --showlist option)
  • optional transparent compression of content (see --compress option)
  • handle running under some folder below / (see --prefix option)
  • graceful shutdown to avoid disrupting long-running connections during deployment (see --timeout.shutdown option)

Configuration

The following settings may be provided as command line arguments or environment variables.

FlagEnv-VarDescriptionDefault
--compressATTO_COMPRESSwhether to transparently compress served filestrue
--loglevel, -lATTO_LOGLEVELlevel of logging output (any value supported by logrus)warn
--portATTO_PORTTCP port on which to listen8080
--pathATTO_PATHpath which will be served.
--path404ATTO_PATHpath to a file returned when the requested content cannot be found404.html
--prefixATTO_PREFIXprefix under which path will be accessednone
--canonical.hostATTO_CANONICAL_HOSTif this host (FQDN) is set, requests using different hosts will be redirected to it (e.g.: www.foo.bar to foo.bar)none
--canonical.statuscodeATTO_CANONICAL_STATUSCODEhttp status code to use for the canonical host redirect302 (temporary)
--showlistATTO_SHOWLISTwhether to display folder contentsfalse
--timeout.readheaderATTO_TIMEOUT_READHEADERtime to wait for request headers5s
--timeout.shutdownATTO_TIMEOUT_SHUTDOWNtime to wait for ungoing requests to finish before shutting down30s

Motivation

The main use-case for atto is simplifying the build/deployment process of applications with static files, so that the same mental toolset can be used both for code and assets.

It is not a replacement for proper production deployment, but can ease the cognitive load when dealing with smaller, less often touched apps.

License

MIT - See LICENSE file.

Docker Pull Command

docker pull costela/atto