glenrobson / SimpleAnnotationServer

A simple IIIF and Mirador compatible Annotation Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some suggestions for `runDocker.sh`

mk-pmb opened this issue · comments

commented

I'd have submitted my changes as a PR, but the repo turned out too huge to clone for just this simple script.

The ideas behind the changes:

  • Convert those elif to case.
  • Deal with upper case characters once, independent of where they came from. The decision statements should have the keywords in plain, so they can be found via text search.
  • Treat empty string given as first CLI argument the same as if there weren't any.
  • docker build … && docker run … should be separate commands. Using global set -e to abort on failure in command combinations isn't my usual style, but it's the flavor that closest matches the previous coding style.
  • Unknown backend should cause the script to exit with a positive (error) return value, not 0 (success).

Docker vs. ufw firewall

Problem: Lots of novice docker users are unaware of how to set the default bind IP address for their containers and are thus surprised if a project's docker scripts bind to ALL available network interfaces without asking. The effect is made worse because those novices usually also don't know that docker's port publishing has priority over ufw rules, so they might expect that the published ports would be firewalled.

Mitigation: I'd recommend a protect-by-default approach where any docker utility scripts included in a project should offer an easy way to configure a bind IP (e.g. via environment variable). In case that config is missing, the script should

  • alert the user about how to configure it,
  • bind to 127.0.0.1,
  • inform the user that the server in this state is usually not available via external network.