mashe commited on
Commit
748cd96
1 Parent(s): 42ff323

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -12
Dockerfile CHANGED
@@ -1,21 +1,18 @@
1
  # Use an official Python runtime as a parent image
2
  FROM python:3.9
3
 
4
- # Install CUDA for GPU support (optional, based on your needs)
5
- # Uncomment the following lines if you need GPU support
6
- # RUN apt-get update && apt-get install -y --no-install-recommends \
7
- # cuda-cudart-dev-11.0 \
8
- # && \
9
- # rm -rf /var/lib/apt/lists/*
10
-
11
  # Set the working directory in the container
12
  WORKDIR /app
13
 
 
 
 
14
  # Copy the current directory contents into the container at /app
15
- COPY . /app
 
16
 
17
  # Install any needed packages specified in requirements.txt
18
- RUN pip install -r requirements.txt
19
 
20
  # Make port 7860 available to the world outside this container
21
  EXPOSE 7860
@@ -24,10 +21,13 @@ EXPOSE 7860
24
  ENV GRADIO_SERVER_PORT=7860
25
 
26
  # Set the HF_HOME environment variable to a writable directory
27
- ENV HF_HOME=/app/.cache/huggingface/hub
 
 
 
28
 
29
- # Create the cache directory if it doesn't exist
30
- RUN mkdir -p $HF_HOME
31
 
32
  # Run app.py when the container launches
33
  CMD ["python", "app.py"]
 
1
  # Use an official Python runtime as a parent image
2
  FROM python:3.9
3
 
 
 
 
 
 
 
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
+ # Create a group and user for running the application
8
+ RUN groupadd mygroup && useradd -ms /bin/bash -G mygroup appuser
9
+
10
  # Copy the current directory contents into the container at /app
11
+ # Use --chown to set the ownership and --chmod to set the permissions
12
+ COPY --chown=appuser:mygroup . /app
13
 
14
  # Install any needed packages specified in requirements.txt
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  # Make port 7860 available to the world outside this container
18
  EXPOSE 7860
 
21
  ENV GRADIO_SERVER_PORT=7860
22
 
23
  # Set the HF_HOME environment variable to a writable directory
24
+ ENV HF_HOME=/app/.cache/huggingface
25
+
26
+ # Create the cache directory if it doesn't exist and set its ownership
27
+ RUN mkdir -p $HF_HOME && chown -R appuser:mygroup $HF_HOME
28
 
29
+ # Switch to the appuser to run the application
30
+ USER appuser
31
 
32
  # Run app.py when the container launches
33
  CMD ["python", "app.py"]