jitubutwal1441 commited on
Commit
f98fdc6
·
verified ·
1 Parent(s): a938912

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -34
Dockerfile CHANGED
@@ -1,42 +1,29 @@
1
- # Use official Python 3.12 base image
2
- FROM python:3.12-slim
3
 
4
- # Install system dependencies
5
- RUN apt-get update && \
6
- apt-get install -y --no-install-recommends \
7
- git curl libgl1 libglib2.0-0 && \
8
- rm -rf /var/lib/apt/lists/*
 
 
 
9
 
10
- # Create a non-root user
11
- RUN useradd -m -u 1000 user
12
 
13
- # Switch to non-root user before copying and installing
14
- USER user
15
 
16
- # Set up home and cache environment variables
17
- ENV HOME=/home/user \
18
- PATH=/home/user/.local/bin:$PATH \
19
- HF_HOME=/home/user/.cache/huggingface \
20
- TRANSFORMERS_CACHE=/home/user/.cache/huggingface/transformers \
21
- HF_DATASETS_CACHE=/home/user/.cache/huggingface/datasets
22
 
23
- # Make sure cache directories are writable
24
- RUN mkdir -p $HF_HOME/hub $TRANSFORMERS_CACHE $HF_DATASETS_CACHE && \
25
- chmod -R 777 /home/user/.cache
26
 
27
- # Set working directory
28
- WORKDIR $HOME/app
29
-
30
- # Copy dependencies and install
31
- COPY --chown=user:user requirements.txt .
32
- RUN pip install --upgrade pip && \
33
- pip install --no-cache-dir -r requirements.txt
34
-
35
- # Copy application code
36
- COPY --chown=user:user . .
37
-
38
- # Expose the default port
39
  EXPOSE 7860
40
 
41
- # Run the FastAPI app
42
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Base image with CUDA and PyTorch
2
+ FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime
3
 
4
+ # Install dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ git \
7
+ curl \
8
+ wget \
9
+ libgl1 \
10
+ libglib2.0-0 \
11
+ && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create app directory
14
+ WORKDIR /app
15
 
16
+ # Copy requirements
17
+ COPY requirements.txt .
18
 
19
+ # Install Python dependencies
20
+ RUN pip install --upgrade pip && pip install -r requirements.txt
 
 
 
 
21
 
22
+ # Copy the rest of the app
23
+ COPY . .
 
24
 
25
+ # Expose port if running a web interface
 
 
 
 
 
 
 
 
 
 
 
26
  EXPOSE 7860
27
 
28
+ # Entry point
29
+ CMD ["python", "app.py"]