January 2019
Intermediate to advanced
520 pages
14h 32m
English
Now everything is ready to build and pack the microservice to an image. To do this, add the Dockerfile file to the folder with the microservice and add the following lines to it:
FROM rust:nightlyRUN USER=root cargo new --bin users-microserviceWORKDIR /users-microserviceCOPY ./Cargo.toml ./Cargo.tomlRUN cargo buildRUN rm src/*.rsCOPY ./src ./srcCOPY ./diesel.toml ./diesel.tomlRUN rm ./target/debug/deps/users_microservice*RUN cargo buildCMD ["./target/debug/users-microservice"]EXPOSE 8000
We created the image based on the rust:nightly images that we created earlier in this chapter. We set it using the FROM command. The next line creates a new crate:
RUN USER=root cargo new --bin users-microservice
You might ask why we did that and ...
Read now
Unlock full access