Spaces:
Sleeping
Sleeping
kwabs22
commited on
Commit
•
032673b
1
Parent(s):
f03a15c
flagged folder needs hf template to avoid error
Browse files- Dockerfile +42 -13
Dockerfile
CHANGED
@@ -1,20 +1,49 @@
|
|
1 |
-
# Use
|
2 |
-
FROM python:3.
|
3 |
|
4 |
-
# Set the working directory in the container
|
5 |
-
WORKDIR /
|
6 |
|
7 |
-
#
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
15 |
|
16 |
-
#
|
17 |
-
|
|
|
18 |
|
19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
CMD ["python", "app.py"]
|
|
|
1 |
+
# Use Python 3.9 as the base image
|
2 |
+
FROM python:3.9
|
3 |
|
4 |
+
# Set the working directory in the Docker container
|
5 |
+
WORKDIR /app
|
6 |
|
7 |
+
# Install system dependencies
|
8 |
+
RUN apt-get update && apt-get install -y \
|
9 |
+
git \
|
10 |
+
build-essential \
|
11 |
+
wget \
|
12 |
+
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
+
# [Optional] Add commands to clone and build any necessary projects here
|
15 |
+
# For example, if you need to build a specific tool or library
|
16 |
|
17 |
+
# Create a virtual environment and activate it
|
18 |
+
RUN python -m venv /opt/venv
|
19 |
+
ENV PATH="/opt/venv/bin:$PATH"
|
20 |
|
21 |
+
# Copy the requirements file and install Python dependencies
|
22 |
+
COPY ./requirements.txt /app/requirements.txt
|
23 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
24 |
|
25 |
+
# Create a new user for added security
|
26 |
+
RUN useradd -m -u 1000 user
|
27 |
+
|
28 |
+
# Switch to the non-root user
|
29 |
+
USER user
|
30 |
+
|
31 |
+
# Set environment variables
|
32 |
+
ENV HOME=/home/user \
|
33 |
+
PATH=/home/user/.local/bin:$PATH \
|
34 |
+
PYTHONPATH=$HOME/app \
|
35 |
+
PYTHONUNBUFFERED=1 \
|
36 |
+
GRADIO_ALLOW_FLAGGING=never \
|
37 |
+
GRADIO_NUM_PORTS=1 \
|
38 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
39 |
+
GRADIO_THEME=huggingface \
|
40 |
+
SYSTEM=spaces
|
41 |
+
|
42 |
+
# Set the working directory to the user's home directory
|
43 |
+
WORKDIR $HOME/app
|
44 |
+
|
45 |
+
# Copy the current directory contents into the container at $HOME/app and set the owner to the user
|
46 |
+
COPY --chown=user . $HOME/app
|
47 |
+
|
48 |
+
# Command to run the application
|
49 |
CMD ["python", "app.py"]
|