File size: 1,792 Bytes
1564563
df9df86
 
 
 
 
65a80ba
df9df86
1564563
 
65a80ba
 
35024bf
65a80ba
 
35024bf
 
65a80ba
 
35024bf
65a80ba
3e73349
65a80ba
 
35024bf
 
3e73349
65a80ba
 
 
 
 
923058c
65a80ba
1564563
65a80ba
 
 
 
 
 
1c5bb63
1564563
 
65a80ba
 
 
 
 
1564563
65a80ba
35024bf
 
 
65a80ba
1564563
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
FROM ubuntu:22.04

# Install Python and necessary packages
RUN apt-get update && apt-get install -y python3.10 python3-pip

# Create a user and necessary directories
RUN useradd -m -u 1001 user && mkdir -p /home/user/app/cache

RUN apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx
RUN git lfs install

# Ensure the cache directory is writable by the user
RUN chown -R user:user /home/user/app/cache && chmod -R 777 /home/user/app/cache

# Install additional packages from packages.txt
RUN --mount=target=/tmp/packages.txt,source=packages.txt apt-get update && \
    xargs -r -a /tmp/packages.txt apt-get install -y && rm -rf /var/lib/apt/lists/*

# Install Python requirements
RUN --mount=target=/tmp/requirements.txt,source=requirements.txt pip install --no-cache-dir -r /tmp/requirements.txt

WORKDIR /home/user/app

# Install specific versions of pip and other packages
RUN pip install --no-cache-dir pip==22.3.1 && \
    pip install --no-cache-dir datasets "huggingface-hub>=0.19" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
RUN pip freeze > /tmp/freeze.txt

# Install Gradio and other dependencies
RUN pip install --no-cache-dir gradio[oauth]==4.38.1 "uvicorn>=0.14.0" spaces

# Copy application files and set correct ownership
COPY --link --chown=1001:1001 ./ /home/user/app

#EXPOSE 7860

# Moved up to where the user is added
#RUN mkdir cache

# Set environment variables
#ENV TRANSFORMERS_CACHE=/home/user/app/cache (deprecated)
ENV HF_HOME=/home/user/app/cache
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV GRADIO_SERVER_PORT=7860

# Switch to the user
USER user

# Copy the app file
COPY app.py .

# Debug: Check permissions of cache directory
RUN ls -l /home/user/app && ls -l /home/user/app/cache

# Run the app
CMD ["python3", "app.py"]