kwabs22 commited on
Commit
032673b
1 Parent(s): f03a15c

flagged folder needs hf template to avoid error

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -13
Dockerfile CHANGED
@@ -1,20 +1,49 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.8-slim
3
 
4
- # Set the working directory in the container
5
- WORKDIR /usr/src/app
6
 
7
- # Copy the current directory contents into the container at /usr/src/app
8
- COPY . .
 
 
 
 
9
 
10
- # Install any needed packages specified in requirements.txt
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Make port 7860 available to the world outside this container
14
- EXPOSE 7860
 
15
 
16
- # Define environment variable
17
- ENV NAME World
 
18
 
19
- # Run app.py when the container launches
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]