mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
separate installation of requirements and source
this should highly increase rebuilding of the image when: - version did not change - requirements didn't change
This commit is contained in:
@ -8,11 +8,11 @@ FROM python:${PYTHON_VERSION}-slim AS python-base
|
|||||||
|
|
||||||
LABEL org.opencontainers.image.authors="mauwii@outlook.de"
|
LABEL org.opencontainers.image.authors="mauwii@outlook.de"
|
||||||
|
|
||||||
# prepare for buildkit cache
|
# Prepare apt for buildkit cache
|
||||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
|
||||||
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
|
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
|
||||||
|
|
||||||
# Install necessary packages
|
# Install dependencies
|
||||||
RUN \
|
RUN \
|
||||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||||
@ -23,7 +23,7 @@ RUN \
|
|||||||
libglib2.0-0=2.66.* \
|
libglib2.0-0=2.66.* \
|
||||||
libopencv-dev=4.5.*
|
libopencv-dev=4.5.*
|
||||||
|
|
||||||
# set working directory and env
|
# Set working directory and env
|
||||||
ARG APPDIR=/usr/src
|
ARG APPDIR=/usr/src
|
||||||
ARG APPNAME=InvokeAI
|
ARG APPNAME=InvokeAI
|
||||||
WORKDIR ${APPDIR}
|
WORKDIR ${APPDIR}
|
||||||
@ -32,7 +32,7 @@ ENV PATH ${APPDIR}/${APPNAME}/bin:$PATH
|
|||||||
ENV PYTHONDONTWRITEBYTECODE 1
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
# Turns off buffering for easier container logging
|
# Turns off buffering for easier container logging
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
# don't fall back to legacy build system
|
# Don't fall back to legacy build system
|
||||||
ENV PIP_USE_PEP517=1
|
ENV PIP_USE_PEP517=1
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
@ -40,7 +40,7 @@ ENV PIP_USE_PEP517=1
|
|||||||
#######################
|
#######################
|
||||||
FROM python-base AS pyproject-builder
|
FROM python-base AS pyproject-builder
|
||||||
|
|
||||||
# Install dependencies
|
# Install build dependencies
|
||||||
RUN \
|
RUN \
|
||||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||||
@ -51,26 +51,39 @@ RUN \
|
|||||||
gcc=4:10.2.* \
|
gcc=4:10.2.* \
|
||||||
python3-dev=3.9.*
|
python3-dev=3.9.*
|
||||||
|
|
||||||
# prepare pip for buildkit cache
|
# Install pip-tools
|
||||||
|
RUN pip install \
|
||||||
|
--no-cache-dir \
|
||||||
|
pip-tools==6.12.2
|
||||||
|
|
||||||
|
# Prepare pip for buildkit cache
|
||||||
ARG PIP_CACHE_DIR=/var/cache/buildkit/pip
|
ARG PIP_CACHE_DIR=/var/cache/buildkit/pip
|
||||||
ENV PIP_CACHE_DIR ${PIP_CACHE_DIR}
|
ENV PIP_CACHE_DIR ${PIP_CACHE_DIR}
|
||||||
RUN mkdir -p ${PIP_CACHE_DIR}
|
RUN mkdir -p ${PIP_CACHE_DIR}
|
||||||
|
|
||||||
# create virtual environment
|
# Create virtual environment
|
||||||
RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \
|
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
|
||||||
python3 -m venv "${APPNAME}" \
|
python3 -m venv "${APPNAME}" \
|
||||||
--upgrade-deps
|
--upgrade-deps
|
||||||
|
|
||||||
# copy sources
|
# Install requirements
|
||||||
COPY --link . .
|
COPY --link pyproject.toml .
|
||||||
|
COPY --link ldm/invoke/_version.py ldm/invoke/__init__.py ldm/invoke/
|
||||||
# install pyproject.toml
|
|
||||||
ARG PIP_EXTRA_INDEX_URL
|
ARG PIP_EXTRA_INDEX_URL
|
||||||
ENV PIP_EXTRA_INDEX_URL ${PIP_EXTRA_INDEX_URL}
|
ENV PIP_EXTRA_INDEX_URL ${PIP_EXTRA_INDEX_URL}
|
||||||
RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \
|
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
|
||||||
|
pip-compile \
|
||||||
|
--resolver=backtracking \
|
||||||
|
--output-file=requirements.txt \
|
||||||
|
pyproject.toml && "${APPNAME}"/bin/pip install \
|
||||||
|
-r requirements.txt
|
||||||
|
|
||||||
|
# Install pyproject.toml
|
||||||
|
COPY --link . .
|
||||||
|
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
|
||||||
"${APPNAME}/bin/pip" install .
|
"${APPNAME}/bin/pip" install .
|
||||||
|
|
||||||
# build patchmatch
|
# Build patchmatch
|
||||||
RUN python3 -c "from patchmatch import patch_match"
|
RUN python3 -c "from patchmatch import patch_match"
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
@ -86,12 +99,12 @@ RUN useradd \
|
|||||||
-U \
|
-U \
|
||||||
"${UNAME}"
|
"${UNAME}"
|
||||||
|
|
||||||
# create volume directory
|
# Create volume directory
|
||||||
ARG VOLUME_DIR=/data
|
ARG VOLUME_DIR=/data
|
||||||
RUN mkdir -p "${VOLUME_DIR}" \
|
RUN mkdir -p "${VOLUME_DIR}" \
|
||||||
&& chown -R "${UNAME}" "${VOLUME_DIR}"
|
&& chown -R "${UNAME}" "${VOLUME_DIR}"
|
||||||
|
|
||||||
# setup runtime environment
|
# Setup runtime environment
|
||||||
USER ${UNAME}
|
USER ${UNAME}
|
||||||
COPY --chown=${UNAME} --from=pyproject-builder ${APPDIR}/${APPNAME} ${APPNAME}
|
COPY --chown=${UNAME} --from=pyproject-builder ${APPDIR}/${APPNAME} ${APPNAME}
|
||||||
ENV INVOKEAI_ROOT ${VOLUME_DIR}
|
ENV INVOKEAI_ROOT ${VOLUME_DIR}
|
||||||
|
Reference in New Issue
Block a user