File size: 3,772 Bytes
54c420d
 
f00d6c6
 
 
 
54c420d
 
 
 
 
 
 
 
 
 
55074b7
f00d6c6
 
 
 
 
 
 
 
 
54c420d
f00d6c6
 
 
54c420d
f00d6c6
 
 
 
 
 
 
 
 
54c420d
a49c947
f00d6c6
54c420d
f00d6c6
 
54c420d
f00d6c6
 
ba3234c
f00d6c6
ba3234c
 
 
792f68e
f00d6c6
cc43224
ce78089
 
9cd0eb3
29bcb24
55074b7
9ac47e0
20fa4c7
f00d6c6
 
 
397bd1f
c170d4b
 
 
 
 
54c420d
 
 
 
 
 
 
 
 
 
f00d6c6
4348d8e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive \ 
    TZ=America/Los_Angeles
    
ARG USE_PERSISTENT_DATA

RUN apt-get update && apt-get install -y \
    git \
    make build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git-lfs  \
    ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install


WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

# User
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Pyenv
RUN curl https://pyenv.run | bash
ENV PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH

ARG PYTHON_VERSION=3.10.12
# Python
RUN pyenv install $PYTHON_VERSION && \
    pyenv global $PYTHON_VERSION && \
    pyenv rehash && \
    pip install --no-cache-dir --upgrade pip setuptools wheel && \
    pip install --no-cache-dir \
    datasets \
    huggingface-hub "protobuf<4" "click<8.1"


RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Set the working directory to /data if USE_PERSISTENT_DATA is set, otherwise set to $HOME/app
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user

RUN  git clone https://github.com/lllyasviel/Fooocus . && \
    # pin to a specific commit
    git checkout fc3588875759328d715fa07cc58178211a894386 && \
    pip install --no-cache-dir /app/xformers==0.0.20 /app/triton==2.0.0 /app/torch==2.0.1 /app/torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118 && \
    pip install --no-cache-dir -r /app/requirements_versions.txt
    

#COPY auth.py $HOME/modules/auth.py


#RUN sed -i "s|def load_auth_data.*|def load_auth_data()   pass|" /home/user/app/modules/auth.py

#ARG FILENAME=auth.json 


# remove the next line if you're running on your own GPU, it set max images to 3 and disables the API
RUN sed -i "s|image_number = gr.Slider(label='Image Number', minimum=1, maximum=32|image_number = gr.Slider(label='Image Number', minimum=1, maximum=3|" webui.py && \
    sed -i "s|shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue()|shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue(concurrency_count=1,api_open=False)|" webui.py && \
    sed -i "s|shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share)|shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share, show_api=False,)|" webui.py


#RUN sed -i "s|image_number = gr.Slider(label='Image Number', minimum=1, maximum=32|image_number = gr.Slider(label='Image Number', minimum=1, maximum=3|" webui.py && \
#    sed -i "s|shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue()|shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue(concurrency_count=1,api_open=False)|" webui.py && \
#    sed -i "s|shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share, auth=("admin", "pass1234"))|shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share, show_api=True, auth=("admin", "pass1234"))|" webui.py

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONPATH=$HOME/app \
    PYTHONUNBUFFERED=1 \
    GRADIO_ALLOW_FLAGGING=never \
    GRADIO_NUM_PORTS=1 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_THEME=huggingface \
    SYSTEM=spaces

CMD ["python", "launch.py"]