2022-10-24 22:01:10 +00:00
|
|
|
FROM ubuntu AS get_miniconda
|
|
|
|
|
|
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
|
|
|
|
# install wget
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
|
|
|
wget \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# download and install miniconda
|
|
|
|
ARG conda_version=py39_4.12.0-Linux-x86_64
|
|
|
|
ARG conda_prefix=/opt/conda
|
|
|
|
RUN wget --progress=dot:giga -O /miniconda.sh \
|
|
|
|
https://repo.anaconda.com/miniconda/Miniconda3-${conda_version}.sh \
|
|
|
|
&& bash /miniconda.sh -b -p ${conda_prefix} \
|
|
|
|
&& rm -f /miniconda.sh
|
|
|
|
|
|
|
|
FROM ubuntu AS invokeai
|
|
|
|
|
|
|
|
# use bash
|
|
|
|
SHELL [ "/bin/bash", "-c" ]
|
|
|
|
|
|
|
|
# clean bashrc
|
|
|
|
RUN echo "" > ~/.bashrc
|
|
|
|
|
|
|
|
# Install necesarry packages
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
|
|
|
--no-install-recommends \
|
|
|
|
gcc \
|
|
|
|
git \
|
|
|
|
libgl1-mesa-glx \
|
|
|
|
libglib2.0-0 \
|
|
|
|
pip \
|
|
|
|
python3 \
|
|
|
|
python3-dev \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2022-11-01 00:34:20 +00:00
|
|
|
# clone repository, create models.yaml and create symlinks
|
2022-11-01 03:09:39 +00:00
|
|
|
ARG invokeai_git=invoke-ai/InvokeAI
|
|
|
|
ARG invokeai_branch=main
|
2022-10-24 22:01:10 +00:00
|
|
|
ARG project_name=invokeai
|
2022-11-10 03:14:35 +00:00
|
|
|
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"
|
2022-10-24 22:01:10 +00:00
|
|
|
|
|
|
|
# set workdir
|
2022-11-10 03:14:35 +00:00
|
|
|
WORKDIR "/${project_name}"
|
2022-10-24 22:01:10 +00:00
|
|
|
|
|
|
|
# install conda env and preload models
|
|
|
|
ARG conda_prefix=/opt/conda
|
2022-11-10 03:14:35 +00:00
|
|
|
COPY --from=get_miniconda "${conda_prefix}" "${conda_prefix}"
|
|
|
|
RUN source "${conda_prefix}/etc/profile.d/conda.sh" \
|
2022-10-24 22:01:10 +00:00
|
|
|
&& conda init bash \
|
|
|
|
&& source ~/.bashrc \
|
|
|
|
&& conda env create \
|
2022-11-10 03:14:35 +00:00
|
|
|
--name "${project_name}" \
|
2022-10-24 22:01:10 +00:00
|
|
|
&& rm -Rf ~/.cache \
|
|
|
|
&& conda clean -afy \
|
2022-11-10 03:14:35 +00:00
|
|
|
&& echo "conda activate ${project_name}" >> ~/.bashrc
|
|
|
|
|
|
|
|
RUN source ~/.bashrc \
|
2022-11-01 00:34:20 +00:00
|
|
|
&& python scripts/preload_models.py \
|
|
|
|
--no-interactive
|
2022-10-24 22:01:10 +00:00
|
|
|
|
|
|
|
# Copy entrypoint and set env
|
2022-11-10 03:14:35 +00:00
|
|
|
ENV CONDA_PREFIX="${conda_prefix}"
|
|
|
|
ENV PROJECT_NAME="${project_name}"
|
2022-10-24 22:01:10 +00:00
|
|
|
COPY docker-build/entrypoint.sh /
|
|
|
|
ENTRYPOINT [ "/entrypoint.sh" ]
|