Spaces:
Sleeping
Sleeping
VatsalPatel18
commited on
Commit
•
200caa8
1
Parent(s):
21f7182
Update Dockerfile
Browse files- Dockerfile +20 -37
Dockerfile
CHANGED
@@ -1,50 +1,33 @@
|
|
1 |
# Use the official Python image as a base image
|
2 |
-
FROM python:3.
|
3 |
-
|
4 |
-
# Set
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
#
|
15 |
-
|
16 |
-
apt-get install -y --no-install-recommends \
|
17 |
-
build-essential \
|
18 |
-
cmake \
|
19 |
-
openssl \
|
20 |
-
wget \
|
21 |
-
&& apt-get clean \
|
22 |
-
&& rm -rf /var/lib/apt/lists/*
|
23 |
|
24 |
# Copy the requirements file
|
25 |
-
COPY requirements.txt /app/
|
26 |
|
27 |
# Install Python dependencies
|
28 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
29 |
|
30 |
-
# Copy
|
31 |
-
COPY
|
32 |
-
|
33 |
-
# Copy the rest of the application code
|
34 |
-
COPY . /app/
|
35 |
|
36 |
# Create the cache directory with appropriate permissions
|
37 |
-
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
|
38 |
-
|
39 |
-
# Ensure the model is downloaded
|
40 |
-
RUN python download_model.py
|
41 |
|
42 |
# Expose the port that Gradio will run on
|
43 |
EXPOSE 7860
|
44 |
|
45 |
-
# Set the user to root
|
46 |
-
USER root
|
47 |
-
|
48 |
# Run the application
|
49 |
-
CMD ["python", "
|
50 |
-
|
|
|
1 |
# Use the official Python image as a base image
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
# Set up a new user named "user" with user ID 1000
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
|
7 |
+
# Switch to the "user" user
|
8 |
+
USER user
|
9 |
+
|
10 |
+
# Set home to the user's home directory
|
11 |
+
ENV HOME=/home/user \
|
12 |
+
PATH=/home/user/.local/bin:$PATH
|
13 |
+
|
14 |
+
# Create working directory and set ownership to the user
|
15 |
+
WORKDIR $HOME/app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Copy the requirements file
|
18 |
+
COPY --chown=user ./requirements.txt $HOME/app/
|
19 |
|
20 |
# Install Python dependencies
|
21 |
+
RUN pip install --no-cache-dir --upgrade -r $HOME/app/requirements.txt
|
22 |
|
23 |
+
# Copy the rest of the application code, setting the owner to the user
|
24 |
+
COPY --chown=user . $HOME/app/
|
|
|
|
|
|
|
25 |
|
26 |
# Create the cache directory with appropriate permissions
|
27 |
+
RUN mkdir -p $HOME/app/hf_cache && chmod -R 777 $HOME/app/hf_cache
|
|
|
|
|
|
|
28 |
|
29 |
# Expose the port that Gradio will run on
|
30 |
EXPOSE 7860
|
31 |
|
|
|
|
|
|
|
32 |
# Run the application
|
33 |
+
CMD ["python", "main.py"]
|
|