Checking your snail mail with Python/Docker and Slack. (Part 2)

Packaging Python scripts with Docker

In Part 1 of this post I covered the creation of the initial MyUsps notification script. There’s quite a few dependencies in the environment required for running this script. At a bare minimum you will need a functional Linux or Windows environment with the following dependencies

There’s some challenges getting all of these things to work well together. It’s also very difficult to keep all of these applications in sync and distribute a working installation script to allow users to clone your environment.

Enter Docker.

Using Docker images we can create a dockerfile that will package images with all the necessary components, and allow for easy distribution of working images. The dockerfile for this project looks like this –

After you have this dockerfile created and stored in your github repo, you can connect your repository to Docker Hub . Docker Hub will create images by running the docker build command on your dockerfile, and will store the resulting images on their servers. The manual equivalent of this process is

In the context of this project, this allows me to distribute my python script as a whole package, that includes all the dependencies in one file, and makes it easier to run. To run my script, all we need to do is run

Then edit the included docker_run.sh file to start our docker container. Head over to the github repository page for this project if you’d like to grab a copy of this script and get further instructions on usage.

Future Improvements

I’m planning on improving this script and making it a provider agnostic notification agent. I plan to support scraping UPS and Fedex in the future. I’m also going to use the Google Vision API . to extract names from pictures of mail and store that in a database, then notify the person that they have mail via a slack private message. Something like this –

After that’s working I am also going to work on converting this script into a full fledged mail checking slack bot! Check back for updates!

 

1 thought on “Checking your snail mail with Python/Docker and Slack. (Part 2)”

  1. Pingback: Checking your snail mail with Python/Docker and Slack. (Part 1) – Ops and Automation

Leave a Comment

Your email address will not be published. Required fields are marked *