Rust build ERROR: context deadline exceeded

If I run this locally or even on local Dockerfile all works fine.
But running same on Google cloud service times out at some random libs.

ERROR:

Compiling toml v0.5.6
Your build timed out. Use the [--timeout=DURATION] flag to change the timeout threshold.
ERROR: (gcloud.builds.submit) build 238b41b1-e427-4681-a7f7-b4288e04a423 completed with status "TIMEOUT"
   Compiling futures-executor v0.3.5
   Compiling h2 v0.2.6

actual error on GCP:

Step #0 - "Build": e[0me[91m e[0me[91m e[0me[91m e[0me[91mCompilinge[0me[91m e[0me[91mtungstenitee[0me[91m ve[0me[91m0.10.1e[0me[91m
TIMEOUT
ERROR: context deadline exceeded

This is my Cargo.toml file

[package]
name = "discord-zbot"
version = "0.1.0"
authors = ["ajinkya"]
edition = "2018"

[dependencies]
serenity = "0.9.0-rc.0"
reqwest = "0.10.8"
tokio = { version = "0.2.22", features = ["full"] }
serde = {version = "1.0.114", features = ["derive"]}
serde_json = "1.0.57"
dotenv = "0.15.0"
config = "0.10.1"
chrono = "0.4.15"

and This is my Dockerfile:

# ------------------------------------------------------------------------------
# Cargo Build Stage
# ------------------------------------------------------------------------------

FROM rust:latest as builder

USER root
WORKDIR     /rust


# Need this for reqwest lib
RUN apt-get update && apt-get -y install gcc-multilib pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*

# Download the cargo target
RUN rustup default stable


# create dummy application, s.t. cargo can download all dependencies
RUN         mkdir -p /rust/app/src && echo 'fn main(){}' > app/src/main.rs
WORKDIR     /rust/app

# Build & cache dependencies
COPY        Cargo.toml Cargo.lock ./
RUN         cargo build --release

# Copy application code
COPY        src ./src

# Build production binary, touch will create file if doesnt exists
RUN         touch src/main.rs && cargo build --release

# Check if binary exists
RUN ls -l /rust/app/target/release/discord-zbot

# Production container
EXPOSE 8080
FROM        scratch
COPY        --from=builder /rust/app/target/release/discord-zbot /app
ENTRYPOINT  ["/app"]

How long is the timeout?

It was 300 initially. Later I made it 600seconds. @bjorn3

serenity has quite a lot of dependencies and tokio can also take a bit. I would not be surprised if both combined takes more than 10min to compile in release mode.

1 Like

Thanks for suggestions. @bjorn3
I increased the timeout to 900seconds (15mins) GCP allows this as maximum.
Also increased RAM to 1GB.

Still Im having same issue. (complete log here)

tungstenite

TIMEOUT
ERROR: context deadline exceeded

Step #0 - "Build": e[0me[91m e[0me[91m e[0me[91m e[0me[91mCompilinge[0me[91m e[0me[91mtokioe[0me[91m ve[0me[91m0.2.22e[0me[91m
Step #0 - "Build": e[0me[91m e[0me[91m e[0me[91m e[0me[91mCompilinge[0me[91m e[0me[91mtungstenitee[0me[91m ve[0me[91m0.10.1e[0me[91m
TIMEOUT
ERROR: context deadline exceeded
Step #0 - "Build": e[0me[91m e[0me[91m e[0me[91m e[0me[91mCompilinge[0me[91m e[0me[91mfutures-utile[0me[91m ve[0me[91m0.3.5e[0me[91m

Can you try compiling it locally without timeout to see how long it takes?

1 Like

Locally it takes max 5minutes.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.