Email microservice image

The email microservice doesn't use the diesel crate and we can use the official Rust image to build a microservice. Also, the email microservice has templates that are used to prepare the contents of emails. We will use the same .dockerignore file, but will copy Dockerfile from the previous example and add some changes related to the email microservice:

FROM rust:1.30.1

RUN USER=root cargo new --bin mails-microservice
WORKDIR /mails-microservice
COPY ./Cargo.toml ./Cargo.toml
RUN cargo build

RUN rm src/*.rs
COPY ./src ./src
COPY ./templates ./templates
RUN rm ./target/debug/deps/mails_microservice*
RUN cargo build

CMD ["./target/debug/mails-microservice"]

We created this image from the rust:1.30.1 image. The stable version of the compiler is suitable to compile this simple microservice. We also added a command to copy all the templates into the image:

COPY ./templates ./templates

Now we can prepare the image with the router microservice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.22.23