Generating Docker images for a Rocket application
Containerization has been a popular choice to ship production applications for a while. One of the most popular applications for containerization is Docker. In this section, we are going to learn how to set up Docker to run our Rocket application. To use the docker
command line, please install Docker Desktop from https://www.docker.com/products/docker-desktop/.
Follow these steps to create and run a Docker image of the Rocket application:
- In the root folder of the application, create a Dockerfile.
- There are some base images we can use to build and run the application. We are going to use Rust's official Docker image from https://hub.docker.com/_/rust. For the Linux distribution, we are going to use Alpine base because it's one of the smallest base images for Docker.
In the Dockerfile, add the first line:
FROM rust:alpine as prepare-stage
- Set the working directory. Append this line to the Dockerfile...