Docker image for delivering AWS S3 logs via AWStats

I had a small project to display some simple stats for, for some static content sitting in an AWS S3 bucket. I could have forwarded everything to Elastic+Kibana and showed some fancy graphs and charts, but I was only being asked for what I could easily produce via AWStats.

In the interests of creating something small, scalable and repeatable, I’ve put the project within an Alpine-based Docker container. When run on its own, it’ll attempt to connect to an S3 bucket and push the logs via AWStats for indexing.

When run with serve as the first argument, it’ll start up a web server with the awstats.pl CGI interface ready to go.

Key points:

  • Yes, it’s possible to run aws-cli within Alpine Linux but you need to make sure you’ve got glibc installed
  • Sticking build params into ‘main’ image build is a bad idea but secrets are good
  • Building perl modules in Alpine is a pain in the arse
  • aws-cli's “examples” folder is 17MB in size. Delete the dreaded path before commiting your Docker image

The project is on GitHub: pull requests welcome.