From 8fb53c7334ba6ffdeb36fe3c68b8a48732a5c68c Mon Sep 17 00:00:00 2001 From: ewezy Date: Fri, 11 Feb 2022 18:56:26 +0800 Subject: [PATCH] Separate dockerfiles into a base and app file --- engines/real-time-ensembler/Dockerfile | 22 +--------------- engines/real-time-ensembler/app.Dockerfile | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 engines/real-time-ensembler/app.Dockerfile diff --git a/engines/real-time-ensembler/Dockerfile b/engines/real-time-ensembler/Dockerfile index 3bb7cfffe..ae250b5ba 100644 --- a/engines/real-time-ensembler/Dockerfile +++ b/engines/real-time-ensembler/Dockerfile @@ -10,24 +10,4 @@ RUN conda env create -f ./environment.yaml && \ rm -rf /root/.cache # Install conda-pack: -RUN conda install -c conda-forge conda-pack - -# Use conda-pack to create a standalone enviornment -# in /venv: -RUN conda-pack -n real-time-ensembler -o /tmp/env.tar && \ - mkdir /venv && cd /venv && tar xf /tmp/env.tar && \ - rm /tmp/env.tar - -RUN /venv/bin/conda-unpack - -FROM debian:latest - -COPY --from=builder /ensembler ./ensembler -COPY --from=builder /pyfunc_ensembler_runner ./pyfunc_ensembler_runner -COPY --from=builder /run.sh /run.sh -COPY --from=builder /venv /venv - -RUN /bin/bash -c ". /venv/bin/activate && \ - python -m pyfunc_ensembler_runner --mlflow_ensembler_dir /ensembler --dry_run" - -CMD ["/bin/bash", "./run.sh"] +RUN conda install -c conda-forge conda-pack \ No newline at end of file diff --git a/engines/real-time-ensembler/app.Dockerfile b/engines/real-time-ensembler/app.Dockerfile new file mode 100644 index 000000000..7962f5743 --- /dev/null +++ b/engines/real-time-ensembler/app.Dockerfile @@ -0,0 +1,30 @@ +ARG BASE_IMAGE + +FROM ${BASE_IMAGE} as builder + +ARG MODEL_URL +RUN gsutil -m cp -r ${MODEL_URL} . +ARG FOLDER_NAME + +# Install dependencies required by the user-defined ensembler +RUN /bin/bash -c ". activate ${CONDA_ENVIRONMENT} && conda env update --name ${CONDA_ENVIRONMENT} --file /${HOME}/${FOLDER_NAME}/conda.yaml" + +# Use conda-pack to create a standalone enviornment +# in /venv: +RUN conda-pack -n real-time-ensembler -o /tmp/env.tar && \ + mkdir /venv && cd /venv && tar xf /tmp/env.tar && \ + rm /tmp/env.tar + +RUN /venv/bin/conda-unpack + +FROM debian:latest + +COPY --from=builder /ensembler ./ensembler +COPY --from=builder /pyfunc_ensembler_runner ./pyfunc_ensembler_runner +COPY --from=builder /run.sh /run.sh +COPY --from=builder /venv /venv + +RUN /bin/bash -c ". /venv/bin/activate && \ + python -m pyfunc_ensembler_runner --mlflow_ensembler_dir /ensembler --dry_run" + +CMD ["/bin/bash", "./run.sh"]