From a5719aabf89c8c5f29c6044e2882ccdcd0c6916b Mon Sep 17 00:00:00 2001 From: mauwii Date: Thu, 10 Nov 2022 04:14:35 +0100 Subject: [PATCH] update Dockerfile - link environment.yml from new environemnts path - change default conda_env_file - quote all variables to avoid splitting - also remove paths from conda-env-files in build-container.yml --- .github/workflows/build-container.yml | 4 +-- docker-build/Dockerfile | 37 +++++++++++++++++---------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 11b21f6b80..ec4a105a9e 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -17,9 +17,9 @@ jobs: - aarch64 include: - arch: x86_64 - conda-env-file: environments-and-requirements/environment-lin-cuda.yml + conda-env-file: environment-lin-cuda.yml - arch: aarch64 - conda-env-file: environments-and-requirements/environment-lin-aarch64.yml + conda-env-file: environment-lin-aarch64.yml runs-on: ubuntu-latest name: ${{ matrix.arch }} steps: diff --git a/docker-build/Dockerfile b/docker-build/Dockerfile index 1de6f778bb..3f20e4b6f0 100644 --- a/docker-build/Dockerfile +++ b/docker-build/Dockerfile @@ -43,33 +43,42 @@ RUN apt-get update \ ARG invokeai_git=invoke-ai/InvokeAI ARG invokeai_branch=main ARG project_name=invokeai -RUN git clone -b ${invokeai_branch} https://github.com/${invokeai_git}.git /${project_name} \ - && cp /${project_name}/configs/models.yaml.example /${project_name}/configs/models.yaml \ - && ln -s /data/models/v1-5-pruned-emaonly.ckpt /${project_name}/models/ldm/stable-diffusion-v1/v1-5-pruned-emaonly.ckpt \ - && ln -s /data/outputs/ /${project_name}/outputs +ARG conda_env_file=environment-lin-cuda.yml +RUN git clone -b ${invokeai_branch} https://github.com/${invokeai_git}.git "/${project_name}" \ + && cp \ + "/${project_name}/configs/models.yaml.example" \ + "/${project_name}/configs/models.yaml" \ + && ln -sf \ + "/${project_name}/environments-and-requirements/${conda_env_file}" \ + "/${project_name}/environment.yml" \ + && ln -sf \ + /data/models/v1-5-pruned-emaonly.ckpt \ + "/${project_name}/models/ldm/stable-diffusion-v1/v1-5-pruned-emaonly.ckpt" \ + && ln -sf \ + /data/outputs/ \ + "/${project_name}/outputs" # set workdir -WORKDIR /${project_name} +WORKDIR "/${project_name}" # install conda env and preload models ARG conda_prefix=/opt/conda -ARG conda_env_file=environment.yml -COPY --from=get_miniconda ${conda_prefix} ${conda_prefix} -RUN source ${conda_prefix}/etc/profile.d/conda.sh \ +COPY --from=get_miniconda "${conda_prefix}" "${conda_prefix}" +RUN source "${conda_prefix}/etc/profile.d/conda.sh" \ && conda init bash \ && source ~/.bashrc \ && conda env create \ - --name ${project_name} \ - --file ${conda_env_file} \ + --name "${project_name}" \ && rm -Rf ~/.cache \ && conda clean -afy \ - && echo "conda activate ${project_name}" >> ~/.bashrc \ - && conda activate ${project_name} \ + && echo "conda activate ${project_name}" >> ~/.bashrc + +RUN source ~/.bashrc \ && python scripts/preload_models.py \ --no-interactive # Copy entrypoint and set env -ENV CONDA_PREFIX=${conda_prefix} -ENV PROJECT_NAME=${project_name} +ENV CONDA_PREFIX="${conda_prefix}" +ENV PROJECT_NAME="${project_name}" COPY docker-build/entrypoint.sh / ENTRYPOINT [ "/entrypoint.sh" ]