|
| 1 | +####################### |
1 | 2 | #### Builder stage ####
|
2 | 3 |
|
3 | 4 | FROM library/ubuntu:22.04 AS builder
|
4 | 5 |
|
5 |
| -ENV DEBIAN_FRONTEND=noninteractive |
6 |
| -ENV PYTHONDONTWRITEBYTECODE=1 |
7 |
| -# unbuffered output, ensures stdout and stderr are printed in the correct order |
8 |
| -ENV PYTHONUNBUFFERED=1 |
9 |
| - |
10 |
| -RUN --mount=type=cache,target=/var/cache/apt \ |
11 |
| - apt update && apt install -y \ |
12 |
| - libglib2.0-0 \ |
13 |
| - libgl1-mesa-glx \ |
14 |
| - python3-venv \ |
15 |
| - python3-pip |
| 6 | +ARG DEBIAN_FRONTEND=noninteractive |
| 7 | +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 |
| 8 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 9 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 10 | + apt update && apt-get install -y \ |
| 11 | + git \ |
| 12 | + libglib2.0-0 \ |
| 13 | + libgl1-mesa-glx \ |
| 14 | + python3-venv \ |
| 15 | + python3-pip \ |
| 16 | + build-essential \ |
| 17 | + python3-opencv \ |
| 18 | + libopencv-dev |
16 | 19 |
|
| 20 | +# This is needed for patchmatch support |
| 21 | +RUN cd /usr/lib/x86_64-linux-gnu/pkgconfig/ &&\ |
| 22 | + ln -sf opencv4.pc opencv.pc |
17 | 23 |
|
18 |
| -ARG APP_ROOT=/invokeai |
19 |
| -WORKDIR ${APP_ROOT} |
| 24 | +ARG WORKDIR=/invokeai |
| 25 | +WORKDIR ${WORKDIR} |
20 | 26 |
|
21 |
| -ENV VIRTUAL_ENV=${APP_ROOT}/.venv |
| 27 | +ENV VIRTUAL_ENV=${WORKDIR}/.venv |
22 | 28 | ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
23 | 29 |
|
24 |
| -COPY . . |
25 | 30 | RUN --mount=type=cache,target=/root/.cache/pip \
|
26 |
| - cp installer/py3.10-linux-x86_64-cuda-reqs.txt requirements.txt && \ |
27 | 31 | python3 -m venv ${VIRTUAL_ENV} &&\
|
28 | 32 | pip install --extra-index-url https://download.pytorch.org/whl/cu116 \
|
29 | 33 | torch==1.12.0+cu116 \
|
30 | 34 | torchvision==0.13.0+cu116 &&\
|
| 35 | + pip install -e git+https://github.com/invoke-ai/PyPatchMatch@0.1.3#egg=pypatchmatch |
| 36 | + |
| 37 | +COPY . . |
| 38 | +RUN --mount=type=cache,target=/root/.cache/pip \ |
| 39 | + cp installer/py3.10-linux-x86_64-cuda-reqs.txt requirements.txt && \ |
31 | 40 | pip install -r requirements.txt &&\
|
32 | 41 | pip install -e .
|
33 | 42 |
|
34 | 43 |
|
| 44 | +####################### |
35 | 45 | #### Runtime stage ####
|
36 | 46 |
|
37 |
| -FROM ubuntu:22.04 as runtime |
38 |
| -RUN apt update && apt install -y \ |
39 |
| - git \ |
40 |
| - curl \ |
41 |
| - ncdu \ |
42 |
| - iotop \ |
43 |
| - bzip2 \ |
44 |
| - libglib2.0-0 \ |
45 |
| - libgl1-mesa-glx \ |
46 |
| - python3-venv \ |
47 |
| - python3-pip \ |
48 |
| - && apt-get clean |
49 |
| - |
50 |
| -ARG APP_ROOT=/invokeai |
51 |
| -WORKDIR ${APP_ROOT} |
52 |
| - |
53 |
| -ENV VIRTUAL_ENV=${APP_ROOT}/.venv |
| 47 | +FROM library/ubuntu:22.04 as runtime |
| 48 | + |
| 49 | +ARG DEBIAN_FRONTEND=noninteractive |
| 50 | +ENV PYTHONUNBUFFERED=1 |
| 51 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 52 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 53 | + apt update && apt install -y --no-install-recommends \ |
| 54 | + git \ |
| 55 | + curl \ |
| 56 | + ncdu \ |
| 57 | + iotop \ |
| 58 | + bzip2 \ |
| 59 | + libglib2.0-0 \ |
| 60 | + libgl1-mesa-glx \ |
| 61 | + python3-venv \ |
| 62 | + python3-pip \ |
| 63 | + build-essential \ |
| 64 | + python3-opencv \ |
| 65 | + libopencv-dev &&\ |
| 66 | + apt-get clean && apt-get autoclean |
| 67 | + |
| 68 | +ARG WORKDIR=/invokeai |
| 69 | +WORKDIR ${WORKDIR} |
| 70 | + |
| 71 | +ENV INVOKEAI_ROOT=/mnt/invokeai |
| 72 | +ENV VIRTUAL_ENV=${WORKDIR}/.venv |
54 | 73 | ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
55 | 74 |
|
56 |
| -COPY --from=builder ${APP_ROOT} ${APP_ROOT} |
| 75 | +COPY --from=builder ${WORKDIR} ${WORKDIR} |
| 76 | +COPY --from=builder /usr/lib/x86_64-linux-gnu/pkgconfig /usr/lib/x86_64-linux-gnu/pkgconfig |
| 77 | + |
| 78 | +# build patchmatch |
| 79 | +RUN python -c "from patchmatch import patch_match" |
| 80 | + |
| 81 | +## workaround for non-existent initfile when runtime directory is mounted; see #1613 |
| 82 | +RUN touch /root/.invokeai |
57 | 83 |
|
58 | 84 | ENTRYPOINT ["bash"]
|
59 | 85 |
|
|
0 commit comments