Sarthak005 commited on
Commit
45f7a2f
·
verified ·
1 Parent(s): 05eaf6f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -18
Dockerfile CHANGED
@@ -1,27 +1,20 @@
1
- # Use the official Python 3.12.6 image
2
  FROM python:3.12.6
3
 
4
- # Create a new group and user
5
- RUN groupadd -r appuser && useradd -r -g appuser appuser
6
 
7
- # Set environment variables for cache directories
8
- ENV TRANSFORMERS_CACHE=/app/hf_cache
9
- ENV HF_HOME=/app/hf_cache
10
 
11
- # Create the cache directory and set permissions
12
- RUN mkdir -p /app/hf_cache && chown -R appuser:appuser /app/hf_cache
13
 
14
- # Set the working directory
15
- WORKDIR /app
16
 
17
- # Copy the current directory contents into the container at /app
18
- COPY --chown=appuser:appuser . /app
19
 
20
- # Install requirements
21
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
22
 
23
- # Switch to the new user
24
- USER appuser
25
 
26
- # Start the FastAPI app on port 7860
27
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
1
  FROM python:3.12.6
2
 
3
+ WORKDIR /code
 
4
 
5
+ COPY ./requirements.txt /code/requirements.txt
 
 
6
 
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
8
 
9
+ RUN useradd -m -u 1000 user
 
10
 
11
+ USER user
 
12
 
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH
15
 
16
+ WORKDIR $HOME/app
 
17
 
18
+ COPY --chown=user . $HOME/app
19
+
20
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]