Call Sim: Speed up docker builds

This commit is contained in:
Jim Gustafson 2026-03-20 10:54:30 -07:00 committed by GitHub
parent 99eed3eba5
commit 81111e97e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 24 deletions

View File

@ -1,5 +1,7 @@
out/
out-arm/
target/
!target/release/call_sim-cli
cscope.*
.DS_Store
.dir-locals.el

View File

@ -1,5 +1,3 @@
# syntax=docker/dockerfile:1.7-labs
#
# Copyright 2023 Signal Messenger, LLC
# SPDX-License-Identifier: AGPL-3.0-only
@ -13,37 +11,30 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests curl build-essential ca-certificates protobuf-compiler \
&& update-ca-certificates
SHELL [ "/bin/bash", "-c"]
# Install Rust.
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Since protobuf is a workspace package, we have to stub the entire workspace
WORKDIR /usr/src/ringrtc
COPY --parents ./**/Cargo.toml ./**/Cargo.lock ./**/main.rs ./**/lib.rs ./**/bin/*.rs ./
RUN shopt -s globstar; shopt -s nullglob; \
for filename in ./**/main.rs; do \
truncate -s 0 "$filename"; \
done; \
for filename in ./**/lib.rs; do \
truncate -s 0 "$filename"; \
done; \
for filename in ./**/bin/*.rs; do \
truncate -s 0 "$filename"; \
done
# stub the signaling server, but remove the actual code first
RUN cd call_sim/docker && \
rm -rf signaling_server && \
cargo new signaling_server
COPY call_sim/docker/signaling_server/Cargo.* ./call_sim/docker/signaling_server/
RUN cd call_sim/docker/signaling_server && cargo build --release
# Copy the source and build the project normally.
# Minimal workspace root so cargo can resolve protobuf's inherited fields.
RUN cat <<'EOF' > Cargo.toml
[workspace]
resolver = "2"
members = ["protobuf"]
[workspace.package]
version = "0.0.0"
authors = []
EOF
# Copy only the crates signaling_server actually depends on.
COPY protobuf protobuf
RUN cd protobuf && cargo build --release
# Copy the signaling_server project.
COPY call_sim/docker/signaling_server call_sim/docker/signaling_server
# Build.
RUN cd call_sim/docker/signaling_server && cargo build --release
FROM ubuntu:22.04 AS run-stage