2022-12-14 19:14:51 +00:00
|
|
|
FROM rust:1.65-bullseye as builder
|
2022-08-22 10:25:07 +00:00
|
|
|
WORKDIR /usr/src/testplan
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y cmake protobuf-compiler
|
|
|
|
|
|
|
|
ARG PLAN_PATH="./"
|
2022-11-23 17:00:19 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-11-18 11:49:30 +00:00
|
|
|
RUN cd ./plan/ && cargo build # Initial build acts as a cache.
|
2022-08-22 10:25:07 +00:00
|
|
|
|
2022-11-18 11:49:30 +00:00
|
|
|
ARG GIT_TARGET=""
|
|
|
|
RUN if [ ! -z "${GIT_TARGET}" ]; then sed -i "s,^git.*,git = \"https://${GIT_TARGET}\"," ./plan/Cargo.toml; fi
|
2022-08-22 10:25:07 +00:00
|
|
|
|
2022-11-18 11:49:30 +00:00
|
|
|
ARG GIT_REF=""
|
2022-12-01 17:25:34 +00:00
|
|
|
RUN if [ ! -z "${GIT_REF}" ]; then sed -i "s,^rev.*,rev = \"${GIT_REF}\"," ./plan/Cargo.toml; fi
|
2022-08-22 10:25:07 +00:00
|
|
|
|
2022-11-23 17:00:19 +00:00
|
|
|
COPY ./plan/${PLAN_PATH}/src/lib.rs ./plan/src/lib.rs
|
|
|
|
COPY ./plan/${PLAN_PATH}/src/bin/ ./plan/src/bin/
|
|
|
|
|
2022-11-18 11:49:30 +00:00
|
|
|
# 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/ \
|
|
|
|
&& cargo build --bin=${BINARY_NAME} \
|
|
|
|
&& mv /usr/src/testplan/plan/target/debug/${BINARY_NAME} /usr/local/bin/testplan
|
2022-08-22 10:25:07 +00:00
|
|
|
|
|
|
|
FROM debian:bullseye-slim
|
2022-11-18 11:49:30 +00:00
|
|
|
COPY --from=builder /usr/local/bin/testplan /usr/local/bin/testplan
|
2022-08-22 10:25:07 +00:00
|
|
|
EXPOSE 6060
|
|
|
|
ENV RUST_BACKTRACE=1
|
2022-11-18 11:49:30 +00:00
|
|
|
ENTRYPOINT ["testplan"]
|