Skip to content

Commit 31a1288

Browse files
feat(ping/rust): Add dummy main to allow for caching of built dependencies (libp2p#78)
1 parent ddb2e4b commit 31a1288

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ping/rust/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ WORKDIR /usr/src/testplan
44
RUN apt-get update && apt-get install -y cmake protobuf-compiler
55

66
ARG PLAN_PATH="./"
7-
COPY ./plan/${PLAN_PATH} ./plan
7+
8+
RUN mkdir -p ./plan/src
9+
COPY ./plan/${PLAN_PATH}/src/main.rs ./plan/src/main.rs
10+
COPY ./plan/${PLAN_PATH}/Cargo.toml ./plan/Cargo.toml
11+
COPY ./plan/${PLAN_PATH}/Cargo.lock ./plan/Cargo.lock
12+
813
RUN cd ./plan/ && cargo build # Initial build acts as a cache.
914

1015
ARG GIT_TARGET=""
@@ -13,6 +18,9 @@ RUN if [ ! -z "${GIT_TARGET}" ]; then sed -i "s,^git.*,git = \"https://${GIT_TAR
1318
ARG GIT_REF=""
1419
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
1520

21+
COPY ./plan/${PLAN_PATH}/src/lib.rs ./plan/src/lib.rs
22+
COPY ./plan/${PLAN_PATH}/src/bin/ ./plan/src/bin/
23+
1624
# Build the requested binary: Cargo will update lockfile on changed manifest (i.e. if one of the above `sed`s patched it).
1725
ARG BINARY_NAME
1826
RUN cd ./plan/ \

ping/rust/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("This is a dummy main file that is used for creating a cache layer inside the docker container.")
3+
}

0 commit comments

Comments
 (0)