diff --git a/.dockerignore b/.dockerignore index d486de70..bf4db78c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,7 @@ out/ out-arm/ +target/ +!target/release/call_sim-cli cscope.* .DS_Store .dir-locals.el diff --git a/call_sim/docker/signaling_server/Dockerfile b/call_sim/docker/signaling_server/Dockerfile index 49dfe2a0..5b577761 100644 --- a/call_sim/docker/signaling_server/Dockerfile +++ b/call_sim/docker/signaling_server/Dockerfile @@ -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