Rust Rocket Web app deployment time > 30minutes

Has anyone had any success with deploying Rust Rocket apps as a web service? My current app works when running locally, however it takes 30-35 minutes to build and deploy.

Is there any way to cache the target directory so it doesn’t have to recompile every single time?

This is my docker file

FROM rust:latest AS builder

RUN rustup target add x86_64-unknown-linux-musl

RUN apt-get -y update && apt-get install musl-tools pkg-config libpq-dev libssl-dev -y

WORKDIR /app

RUN USER=root cargo new --bin data-api

WORKDIR /app/data-api

COPY . ./

RUN env

RUN cargo build --release --target-dir .

FROM debian

RUN apt-get -y update

RUN apt-get install libpq-dev openssl ca-certificates -y

COPY --from=builder /app/data-api/target/release/data-api /usr/local/bin/data-api

ENV ROCKET_ADDRESS=0.0.0.0

ENV ROCKET_LOG=normal

EXPOSE 8000

CMD ["data-api"]

I don’t have the target directory in my git repo either.
ANy ideas or examples would be much appreciated. I’ve struggled trying to get it to run for about 6 hours and the 30-minute build times are killing be.

Hey Joseph,

What’s showing up in your deploy logs? Are there any errors, or do you notice any delays between the log entries? Does it feel like things are just slow, or do they sometimes seem to hang? What have you tried so far? And is this slow build/deploy issue happening every time?

Jérémy.
Render Support, UTC+3

Hey Jeremy,

The deploy logs seem to be working just fine. The deployment slowly chugs along. The main issue is I think the dependencies are redownloaded and compiled every time. This usually takes about 20 minutes and then the build of my crate starts. I do think that 20 minutes is a long time to compile the dependencies but it could just be the build server isn’t that powerful.

I’m currently trying to figure out if I can build the dependencies separately so that Docker doesn’t try to recompile them every time. So far no luck.

Yes, the slow deploy build is every time.

As a side note for anyone reading this
I was wondering if anyone has had any success good reading with compiling the dependencies before building their rust project.

Hey,

If you’d prefer not to run your build step on Render for any reason, you can opt to deploy a pre-built image instead. Check out https://docs.render.com/deploy-an-image for a detailed guide on how this works. This lets you build your application using another provider or method and just upload and serve the finished image on Render.

Jérémy.
Render Support, UTC+3