We have prepared the Dockerfile to build an image that first builds all the dependencies for our microservice and then builds all the source code. To start this process, you have to use the Docker build command:
docker build -t users-microservice:latest
When you run this command, you will see how Docker prepares files to build an image and builds all the dependencies, but only for the empty crate without the sources of a microservice:
Sending build context to Docker daemon 13.82kB
Step 1/12 : FROM rust:nightly
---> 91e52fb2cea5
Step 2/12 : RUN USER=root cargo new --bin users-microservice
---> Running in 3ff6b18a9c72
Created binary (application) `users-microservice` package
Removing intermediate container 3ff6b18a9c72
---> 85f700c4a567
Step 3/12 : WORKDIR /users-microservice
---> Running in eff894de0a40
Removing intermediate container eff894de0a40...