Deploying rust with Docker and Kubernetes
Hello! My name is Chris Allen and I'm going to use a tiny Rust app to demonstrate deploying Rust with Docker and Kubernetes. Rust and Haskell apps are deployed in similar ways. Much of this is because the compilers for both languages generate native binary executables.
Here are the technologies we'll be using and why:
Totto the bot-o
First, here's our Rust application:
This is identical to the lovely example provided by the telegram-bot library. All it does is run a Telegram bot which repeats back what you said.
To build this locally for development purposes, you would run:
in your terminal. You'll also need the
To run this application and see if it works locally, you will first need to have a Telegram account. Once you're on Telegram, you'll want to talk to the botfather to get an API token for your instance of Totto. From there, you could run the application on MacOS or Linux by doing the following:
The name of the application after
If you direct message the bot the word “ping”, it'll reply with:
as a Telegram reply to your message, where
One thing I wanted to demonstrate was building a conventional runtime container environment for a Rust application as well as a minimal one that could be as small as possible.
For a more conventional Docker environment, you could look at this Dockerfile:
We're pinning the SHA256 hash of the
There are two main things we need in the runtime environment for our Rust application to function:
To furnish these requirements, we have:
Posted by Chris Allen - 17 July, 2018