Skip to content

Commit

Permalink
feat(ping/rust): Add dummy main to allow for caching of built depende…
Browse files Browse the repository at this point in the history
…ncies (#78)
  • Loading branch information
thomaseizinger authored Nov 23, 2022
1 parent ddb2e4b commit 31a1288
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ping/rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ WORKDIR /usr/src/testplan
RUN apt-get update && apt-get install -y cmake protobuf-compiler

ARG PLAN_PATH="./"
COPY ./plan/${PLAN_PATH} ./plan

RUN mkdir -p ./plan/src
COPY ./plan/${PLAN_PATH}/src/main.rs ./plan/src/main.rs
COPY ./plan/${PLAN_PATH}/Cargo.toml ./plan/Cargo.toml
COPY ./plan/${PLAN_PATH}/Cargo.lock ./plan/Cargo.lock

RUN cd ./plan/ && cargo build # Initial build acts as a cache.

ARG GIT_TARGET=""
Expand All @@ -13,6 +18,9 @@ RUN if [ ! -z "${GIT_TARGET}" ]; then sed -i "s,^git.*,git = \"https://${GIT_TAR
ARG GIT_REF=""
RUN if [ "master" = "${GIT_REF}" ]; then sed -i "s/^rev.*/branch= \"master\"/" ./plan/Cargo.toml; elif [ ! -z "${GIT_REF}" ]; then sed -i "s/^rev.*/rev = \"${GIT_REF}\"/" ./plan/Cargo.toml; fi

COPY ./plan/${PLAN_PATH}/src/lib.rs ./plan/src/lib.rs
COPY ./plan/${PLAN_PATH}/src/bin/ ./plan/src/bin/

# Build the requested binary: Cargo will update lockfile on changed manifest (i.e. if one of the above `sed`s patched it).
ARG BINARY_NAME
RUN cd ./plan/ \
Expand Down
3 changes: 3 additions & 0 deletions ping/rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("This is a dummy main file that is used for creating a cache layer inside the docker container.")
}

0 comments on commit 31a1288

Please sign in to comment.