File size: 2,242 Bytes
f6013d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM continuumio/anaconda3:main

WORKDIR /code
COPY ./environment.yml /code/environment.yml

# Create the environment using the environment.yml file
RUN conda env create -f /code/environment.yml

# install pip packages to the gradio environment
# when adjusting the dockerfile on huggingface:
# - if the dockerfile is successfully compileds, a new space need to be initialized and push the changes accordingly
# - otherwise, you can commit to the failed build dockerfile for debugging
RUN conda run -n gradio pip install --upgrade pip
# RUN conda run -n gradio pip install diffusers["torch"] transformers accelerate xformers
# RUN conda run -n gradio pip install gradio 
# RUN conda run -n gradio pip install controlnet-aux
# RUN conda install -n gradio pytorch3d -c pytorch3d -c conda-forge
# RUN conda install -n gradio -c conda-forge open-clip-torch pytorch-lightning
# RUN conda run -n gradio pip install trimesh xatlas scikit-learn opencv-python omegaconf

# Set the environment variable to use the gradio environment by default
# RUN echo "source activate gradio" > ~/.bashrc
# ENV PATH /opt/conda/envs/gradio/bin:$PATH

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user

RUN conda create -n gradio-user python=3.11
RUN conda run -n gradio-user pip install --upgrade pip
RUN conda run -n gradio-user pip install diffusers["torch"] transformers accelerate xformers
RUN conda run -n gradio-user pip install gradio 
RUN conda run -n gradio-user pip install controlnet-aux
RUN conda install -n gradio-user pytorch3d -c pytorch3d -c conda-forge
RUN conda install -n gradio-user -c conda-forge open-clip-torch pytorch-lightning
RUN conda run -n gradio-user pip install trimesh xatlas scikit-learn opencv-python omegaconf

# Set home to the user's home directory
ENV HOME=/home/user \
    PYTHONPATH=$HOME/app \
    PYTHONUNBUFFERED=1 \
    GRADIO_ALLOW_FLAGGING=never \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_THEME=huggingface \
    SYSTEM=spaces
# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

CMD ["./run.sh"]