lyimo commited on
Commit
25cf486
1 Parent(s): c4feae9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -18
Dockerfile CHANGED
@@ -1,29 +1,32 @@
1
- # Use the official Python image from the Docker Hub
2
- FROM python:3.9-slim
3
 
4
- # Set the working directory
5
- WORKDIR /app
6
 
7
- # Copy the requirements file into the container
8
- COPY requirements.txt .
9
 
10
- # Install the dependencies
11
- RUN apt-get update && apt-get install -y git && \
12
- pip install torch && \
13
- pip install -r requirements.txt
14
 
15
- # Set environment variables for cache and API key
16
- ENV HF_HOME=/app/.cache/huggingface
17
- ENV OPENAI_API_KEY=your_openai_api_key_here
18
 
19
- # Create cache directory and set permissions
20
- RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache
 
 
 
 
 
 
21
 
22
  # Copy the rest of the application code into the container
23
- COPY . .
 
 
 
24
 
25
  # Expose the port the app runs on
26
  EXPOSE 8000
27
 
28
- # Run the application
29
- CMD ["python", "main.py"]
 
1
+ FROM python:3.9
 
2
 
3
+ # Set up working directory and install dependencies
4
+ WORKDIR /code
5
 
6
+ COPY ./requirements.txt /code/requirements.txt
 
7
 
8
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
9
 
10
+ # Create a new user and set permissions
11
+ RUN useradd -m -u 1000 user
 
12
 
13
+ USER user
14
+
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH \
17
+ HF_HOME=/home/user/.cache/huggingface \
18
+ OPENAI_API_KEY=your_openai_api_key_here
19
+
20
+ WORKDIR $HOME/app
21
 
22
  # Copy the rest of the application code into the container
23
+ COPY --chown=user . $HOME/app
24
+
25
+ # Ensure the cache directory has proper permissions
26
+ RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
27
 
28
  # Expose the port the app runs on
29
  EXPOSE 8000
30
 
31
+ # Run the application using uvicorn
32
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]