I am deploying a Rust API (Actix) on a resource limited server (which runs out of memory trying to compile the api). So I set up a docker based build process so that I can build on my developer machine and push the resulting binary to the server.
I mount the "target" directory into the docker image. My Dockerfile looks like this:
# Install dependencies
RUN yum update -y && \
yum install -y openssl-devel && \
yum install -y rust cargo
RUN mkdir -p /opt/api/src
COPY Cargo.toml /opt/api
COPY Cargo.lock /opt/api
COPY src /opt/api/src
CMD cargo build --release
And in my compose.yaml I mount the target directory like this:
I figured that would enable incremental builds. i.e. it would only recompile what has changed ... but everytime I run
docker compose up it insists on recompiling everything. Any ideas on how I can avoid the full recompile?