I am packaging a rust app to a docker image to deploy to my server. I found the rust docker image size to be more than 1GB (larger than any other app using java and python). Why is the rust docker image so huge? I checked the layer and found the cargo build command takes more than 400MB.
FROM rust:1.54
LABEL maintainer="jiangtingqiang@gmail.com"
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=11014
WORKDIR /app
COPY . .
RUN rustup default stable
RUN cargo build
CMD ["cargo", "run"]
Is it possible to make the rust docker image smaller?