by Joseph Anthony C. Hermocilla, Principal Consultant
URL Shorteners allow users to convert very long URLs into shorter ones that are easier to remember. While preparing my presentation for a workshop, I decided that I could just make Heralli's own URL shortener instead of using popular products such as bit.ly and tiny.url. The result is GoShrt, a Flask App with SQLite3 as the database. The codebase is largely borrowed from this very nice DO tutorial. I Docker-ized the app so that it is easier to deploy. I also added Captcha to prevent bots from abusing the app.
One of the challenges I encountered while developing and deploying GoShrt is how to persist the contents of the database across container restarts. The solution is to use docker volumes. Only the source code for the app is placed in the container, the database is in a volume that is mounted on the container.
Shown below are the contents of docker-compose.yml and Dockerfile, respectively, to achieve this.