mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
update Dockerfile, .dockerignore and workflow
- dont build frontend since complications with QEMU - set pip cache dir - add pip cache to all pip related build steps - dont lock pip cache - update dockerignore to exclude uneeded files
This commit is contained in:
parent
90656aa7bf
commit
1c197c602f
@ -1,19 +1,21 @@
|
|||||||
# use this file as a whitelist
|
# use this file as a whitelist
|
||||||
*
|
*
|
||||||
!backend
|
|
||||||
!invokeai
|
!invokeai
|
||||||
!ldm
|
!ldm
|
||||||
!pyproject.toml
|
!pyproject.toml
|
||||||
!README.md
|
!README.md
|
||||||
!scripts
|
|
||||||
|
|
||||||
# Guard against pulling in any models that might exist in the directory tree
|
# Guard against pulling in any models that might exist in the directory tree
|
||||||
**/*.pt*
|
**/*.pt*
|
||||||
**/*.ckpt
|
**/*.ckpt
|
||||||
|
|
||||||
# whitelist frontend, but ignore node_modules
|
# ignore frontend but whitelist dist
|
||||||
invokeai/frontend/node_modules
|
invokeai/frontend/**
|
||||||
invokeai/frontend/dist/**
|
!invokeai/frontend/dist
|
||||||
|
|
||||||
|
# ignore invokeai/assets but whitelist invokeai/assets/web
|
||||||
|
invokeai/assets
|
||||||
|
!invokeai/assets/web
|
||||||
|
|
||||||
# ignore python cache
|
# ignore python cache
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
|
8
.github/workflows/build-container.yml
vendored
8
.github/workflows/build-container.yml
vendored
@ -47,16 +47,18 @@ jobs:
|
|||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
type=sha
|
type=raw,value='sha'-{{sha}}-${{ matrix.flavor}}
|
||||||
|
type=raw,value={{branch}}-${{ matrix.flavor }}
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=${{ matrix.flavor == 'cuda' && github.ref == 'refs/heads/main' }}
|
latest=${{ matrix.flavor == 'cuda' && github.ref == 'refs/heads/main' }}
|
||||||
suffix=${{ matrix.flavor }},onlatest=false
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
platforms: ${{ matrix.platforms }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@ -67,7 +69,7 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build container
|
- name: Build container
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ${{ matrix.dockerfile }}
|
file: ${{ matrix.dockerfile }}
|
||||||
|
@ -15,7 +15,8 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean
|
|||||||
RUN \
|
RUN \
|
||||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||||
apt-get update \
|
apt-get update \
|
||||||
&& apt-get install -y \
|
&& apt-get install \
|
||||||
|
-yqq \
|
||||||
--no-install-recommends \
|
--no-install-recommends \
|
||||||
libgl1-mesa-glx=20.3.* \
|
libgl1-mesa-glx=20.3.* \
|
||||||
libglib2.0-0=2.66.* \
|
libglib2.0-0=2.66.* \
|
||||||
@ -28,38 +29,24 @@ ARG APPNAME=InvokeAI
|
|||||||
WORKDIR ${APPDIR}
|
WORKDIR ${APPDIR}
|
||||||
ENV PATH=${APPDIR}/${APPNAME}/bin:$PATH
|
ENV PATH=${APPDIR}/${APPNAME}/bin:$PATH
|
||||||
|
|
||||||
######################
|
#######################
|
||||||
## build frontend ##
|
## build pyproject ##
|
||||||
######################
|
#######################
|
||||||
FROM node:lts as frontend-builder
|
|
||||||
|
|
||||||
# Copy Sources
|
|
||||||
ARG APPDIR=/usr/src
|
|
||||||
ARG FRONTEND_DIR=invokeai/frontend
|
|
||||||
WORKDIR ${APPDIR}/${FRONTEND_DIR}
|
|
||||||
COPY ${FRONTEND_DIR} .
|
|
||||||
|
|
||||||
# install dependencies
|
|
||||||
RUN \
|
|
||||||
--mount=type=cache,target=/usr/local/share/.cache/yarn \
|
|
||||||
yarn install \
|
|
||||||
--frozen-lockfile \
|
|
||||||
--non-interactive
|
|
||||||
|
|
||||||
# build frontend
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
###################################
|
|
||||||
## install python dependencies ##
|
|
||||||
###################################
|
|
||||||
FROM python-base AS pyproject-builder
|
FROM python-base AS pyproject-builder
|
||||||
ENV PIP_USE_PEP517=1
|
ENV PIP_USE_PEP517=1
|
||||||
|
|
||||||
|
# prepare for buildkit cache
|
||||||
|
ARG PIP_CACHE_DIR=/var/cache/buildkit/pip
|
||||||
|
ENV PIP_CACHE_DIR ${PIP_CACHE_DIR}
|
||||||
|
RUN mkdir -p ${PIP_CACHE_DIR}
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN \
|
RUN \
|
||||||
|
--mount=type=cache,target=${PIP_CACHE_DIR} \
|
||||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||||
apt-get update \
|
apt-get update \
|
||||||
&& apt-get install -y \
|
&& apt-get install \
|
||||||
|
-yqq \
|
||||||
--no-install-recommends \
|
--no-install-recommends \
|
||||||
build-essential=12.9 \
|
build-essential=12.9 \
|
||||||
gcc=4:10.2.* \
|
gcc=4:10.2.* \
|
||||||
@ -67,19 +54,18 @@ RUN \
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# create virtual environment
|
# create virtual environment
|
||||||
RUN python3 -m venv "${APPNAME}" \
|
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
|
||||||
|
python3 -m venv "${APPNAME}" \
|
||||||
--upgrade-deps
|
--upgrade-deps
|
||||||
|
|
||||||
# copy sources
|
# copy sources
|
||||||
COPY --link . .
|
COPY --link . .
|
||||||
ARG FRONTEND_DIR=invokeai/frontend
|
|
||||||
COPY --from=frontend-builder ${APPDIR}/${FRONTEND_DIR}/dist ${FRONTEND_DIR}/dist
|
|
||||||
|
|
||||||
# install pyproject.toml
|
# 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}
|
||||||
ARG PIP_PACKAGE=.
|
ARG PIP_PACKAGE=.
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
|
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
|
||||||
"${APPDIR}/${APPNAME}/bin/pip" install ${PIP_PACKAGE}
|
"${APPDIR}/${APPNAME}/bin/pip" install ${PIP_PACKAGE}
|
||||||
|
|
||||||
# build patchmatch
|
# build patchmatch
|
||||||
@ -91,7 +77,7 @@ RUN python3 -c "from patchmatch import patch_match"
|
|||||||
FROM python-base AS runtime
|
FROM python-base AS runtime
|
||||||
|
|
||||||
# setup environment
|
# setup environment
|
||||||
COPY --from=pyproject-builder ${APPDIR}/${APPNAME} ${APPDIR}/${APPNAME}
|
COPY --from=pyproject-builder --link ${APPDIR}/${APPNAME} ${APPDIR}/${APPNAME}
|
||||||
ENV INVOKEAI_ROOT=/data
|
ENV INVOKEAI_ROOT=/data
|
||||||
ENV INVOKE_MODEL_RECONFIGURE="--yes --default_only"
|
ENV INVOKE_MODEL_RECONFIGURE="--yes --default_only"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user