rajkhanke commited on
Commit
cc2fe49
·
verified ·
1 Parent(s): d056ab9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -15
Dockerfile CHANGED
@@ -1,23 +1,24 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
- # Set environment variables so Flask knows to bind on all interfaces and use port 8080
5
- ENV FLASK_APP=app.py
6
- ENV FLASK_RUN_HOST=0.0.0.0
7
- ENV FLASK_RUN_PORT=7860
8
-
9
- # Set the working directory in the container
10
  WORKDIR /app
11
 
12
- # Copy requirements.txt and install dependencies
13
- COPY requirements.txt requirements.txt
14
- RUN pip install --upgrade pip && pip install -r requirements.txt
 
 
 
 
 
 
15
 
16
- # Copy the rest of your application code to the container
17
- COPY . .
 
18
 
19
- # Expose the port the app runs on
20
- EXPOSE 7860
 
21
 
22
- # Use Gunicorn to run the Flask app in production
23
  CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
 
 
1
  FROM python:3.9-slim
2
 
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
+ # Copy and install requirements
6
+ COPY requirements.txt /app/requirements.txt
7
+ RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
8
+
9
+ # Set up a new non-root user
10
+ RUN useradd -m -u 1000 user
11
+ USER user
12
+ ENV HOME=/home/user
13
+ ENV PATH=/home/user/.local/bin:$PATH
14
 
15
+ # Create a cache directory and set environment variable
16
+ RUN mkdir -p /home/user/.cache && chown -R user:user /home/user/.cache
17
+ ENV HF_HOME=/home/user/.cache
18
 
19
+ # Set working directory to the user's app directory
20
+ WORKDIR $HOME/app
21
+ COPY --chown=user . $HOME/app
22
 
23
+ EXPOSE 8080
24
  CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]