Update Dockerfile
Browse files- Dockerfile +30 -5
Dockerfile
CHANGED
@@ -2,22 +2,47 @@ FROM ubuntu:22.04
|
|
2 |
RUN apt-get update
|
3 |
RUN apt-get install -y python3.10
|
4 |
RUN apt-get install python3-pip -y
|
5 |
-
RUN useradd -m -u 1001 user
|
6 |
RUN apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx
|
7 |
RUN git lfs install
|
|
|
|
|
|
|
|
|
|
|
8 |
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/*
|
|
|
|
|
9 |
RUN --mount=target=/tmp/requirements.txt,source=requirements.txt pip install --no-cache-dir -r /tmp/requirements.txt
|
|
|
10 |
WORKDIR /home/user/app
|
|
|
|
|
11 |
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"
|
12 |
RUN pip freeze > /tmp/freeze.txt
|
13 |
-
|
14 |
-
#
|
|
|
|
|
|
|
15 |
COPY --link --chown=1001 ./ /home/user/app
|
|
|
16 |
#EXPOSE 7860
|
17 |
-
|
18 |
-
#
|
|
|
|
|
|
|
|
|
19 |
ENV HF_HOME=/home/user/app/cache
|
20 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
21 |
ENV GRADIO_SERVER_PORT=7860
|
|
|
|
|
|
|
|
|
|
|
22 |
COPY app.py .
|
|
|
|
|
23 |
CMD ["python3", "app.py"]
|
|
|
2 |
RUN apt-get update
|
3 |
RUN apt-get install -y python3.10
|
4 |
RUN apt-get install python3-pip -y
|
5 |
+
RUN useradd -m -u 1001 user && mkdir -p /home/user/app/cache
|
6 |
RUN apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx
|
7 |
RUN git lfs install
|
8 |
+
|
9 |
+
# Ensure the cache directory is writable by the user
|
10 |
+
RUN chown -R user:user /home/user/app/cache
|
11 |
+
|
12 |
+
# Install additional packages from packages.txt
|
13 |
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/*
|
14 |
+
|
15 |
+
# Install Python requirements
|
16 |
RUN --mount=target=/tmp/requirements.txt,source=requirements.txt pip install --no-cache-dir -r /tmp/requirements.txt
|
17 |
+
|
18 |
WORKDIR /home/user/app
|
19 |
+
|
20 |
+
# Install specific versions of pip and other packages
|
21 |
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"
|
22 |
RUN pip freeze > /tmp/freeze.txt
|
23 |
+
|
24 |
+
# Install Gradio and other dependencies
|
25 |
+
RUN pip install --no-cache-dir gradio[oauth]==4.38.1 "uvicorn>=0.14.0" spaces
|
26 |
+
|
27 |
+
# Copy application files and set correct ownership
|
28 |
COPY --link --chown=1001 ./ /home/user/app
|
29 |
+
|
30 |
#EXPOSE 7860
|
31 |
+
|
32 |
+
# Moved up to where the user is added
|
33 |
+
#RUN mkdir cache
|
34 |
+
|
35 |
+
# Set environment variables
|
36 |
+
#ENV TRANSFORMERS_CACHE=/home/user/app/cache (deprecated)
|
37 |
ENV HF_HOME=/home/user/app/cache
|
38 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
39 |
ENV GRADIO_SERVER_PORT=7860
|
40 |
+
|
41 |
+
# Switch to the user
|
42 |
+
USER user
|
43 |
+
|
44 |
+
# Copy the app file
|
45 |
COPY app.py .
|
46 |
+
|
47 |
+
# Run the app
|
48 |
CMD ["python3", "app.py"]
|