mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
update Dockerfile
This commit is contained in:
parent
4635836ebc
commit
eb7ccc356f
@ -1,57 +1,74 @@
|
|||||||
FROM debian
|
FROM ubuntu AS get_miniconda
|
||||||
|
|
||||||
ARG gsd
|
SHELL ["/bin/bash", "-c"]
|
||||||
ENV GITHUB_STABLE_DIFFUSION $gsd
|
|
||||||
|
|
||||||
ARG rsd
|
# install wget
|
||||||
ENV REQS $rsd
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y \
|
||||||
|
wget \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ARG cs
|
# download and install miniconda
|
||||||
ENV CONDA_SUBDIR $cs
|
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
|
||||||
|
|
||||||
ENV PIP_EXISTS_ACTION="w"
|
FROM ubuntu AS invokeai
|
||||||
|
|
||||||
# TODO: Optimize image size
|
# use bash
|
||||||
|
SHELL [ "/bin/bash", "-c" ]
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
# clean bashrc
|
||||||
|
RUN echo "" > ~/.bashrc
|
||||||
|
|
||||||
WORKDIR /
|
# Install necesarry packages
|
||||||
RUN apt update && apt upgrade -y \
|
RUN apt-get update \
|
||||||
&& apt install -y \
|
&& apt-get install -y \
|
||||||
git \
|
--no-install-recommends \
|
||||||
libgl1-mesa-glx \
|
gcc \
|
||||||
libglib2.0-0 \
|
git \
|
||||||
pip \
|
libgl1-mesa-glx \
|
||||||
python3 \
|
libglib2.0-0 \
|
||||||
&& git clone $GITHUB_STABLE_DIFFUSION
|
pip \
|
||||||
|
python3 \
|
||||||
|
python3-dev \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Anaconda or Miniconda
|
# clone repository and create symlinks
|
||||||
COPY anaconda.sh .
|
ARG invokeai_git=https://github.com/invoke-ai/InvokeAI.git
|
||||||
RUN bash anaconda.sh -b -u -p /anaconda && /anaconda/bin/conda init bash
|
ARG project_name=invokeai
|
||||||
|
RUN git clone ${invokeai_git} /${project_name} \
|
||||||
|
&& mkdir /${project_name}/models/ldm/stable-diffusion-v1 \
|
||||||
|
&& ln -s /data/models/sd-v1-4.ckpt /${project_name}/models/ldm/stable-diffusion-v1/model.ckpt \
|
||||||
|
&& ln -s /data/outputs/ /${project_name}/outputs
|
||||||
|
|
||||||
# SD
|
# set workdir
|
||||||
WORKDIR /stable-diffusion
|
WORKDIR /${project_name}
|
||||||
RUN source ~/.bashrc \
|
|
||||||
&& conda create -y --name ldm && conda activate ldm \
|
|
||||||
&& conda config --env --set subdir $CONDA_SUBDIR \
|
|
||||||
&& pip3 install -r $REQS \
|
|
||||||
&& pip3 install basicsr facexlib realesrgan \
|
|
||||||
&& mkdir models/ldm/stable-diffusion-v1 \
|
|
||||||
&& ln -s "/data/sd-v1-4.ckpt" models/ldm/stable-diffusion-v1/model.ckpt
|
|
||||||
|
|
||||||
# Face restoreation
|
# install conda env and preload models
|
||||||
# by default expected in a sibling directory to stable-diffusion
|
ARG conda_prefix=/opt/conda
|
||||||
WORKDIR /
|
ARG conda_env_file=environment.yml
|
||||||
RUN git clone https://github.com/TencentARC/GFPGAN.git
|
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} \
|
||||||
|
&& rm -Rf ~/.cache \
|
||||||
|
&& conda clean -afy \
|
||||||
|
&& echo "conda activate ${project_name}" >> ~/.bashrc \
|
||||||
|
&& ln -s /data/models/GFPGANv1.4.pth ./src/gfpgan/experiments/pretrained_models/GFPGANv1.4.pth \
|
||||||
|
&& conda activate ${project_name} \
|
||||||
|
&& python scripts/preload_models.py
|
||||||
|
|
||||||
WORKDIR /GFPGAN
|
# Copy entrypoint and set env
|
||||||
RUN pip3 install -r requirements.txt \
|
ENV CONDA_PREFIX=${conda_prefix}
|
||||||
&& python3 setup.py develop \
|
ENV PROJECT_NAME=${project_name}
|
||||||
&& ln -s "/data/GFPGANv1.4.pth" experiments/pretrained_models/GFPGANv1.4.pth
|
COPY docker-build/entrypoint.sh /
|
||||||
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
WORKDIR /stable-diffusion
|
|
||||||
RUN python3 scripts/preload_models.py
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
COPY entrypoint.sh .
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user