Prasanta4 commited on
Commit
edec91c
·
verified ·
1 Parent(s): d64ae85

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +10 -16
dockerfile CHANGED
@@ -1,37 +1,31 @@
1
- FROM python:3.9-slim
2
 
3
- # Set working directory
4
  WORKDIR /code
5
 
6
  # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
8
- build-essential \
9
  libpng-dev \
10
  libjpeg-dev \
11
- && apt-get clean \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Copy requirements first for better caching
15
- COPY requirements.txt .
16
-
17
- # Install Python dependencies
18
- RUN pip install --no-cache-dir --upgrade pip && \
19
- pip install --no-cache-dir -r requirements.txt
20
-
21
- # Copy application files
22
- COPY . .
23
 
24
- # Create user
25
  RUN useradd -m -u 1000 user
26
  USER user
27
  ENV HOME=/home/user \
28
  PATH=/home/user/.local/bin:$PATH
29
 
 
30
  WORKDIR $HOME/app
 
 
31
  COPY --chown=user . $HOME/app
32
 
33
- # Expose port
34
  EXPOSE 7860
35
 
36
- # Run the application
37
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.9
2
 
 
3
  WORKDIR /code
4
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
 
7
  libpng-dev \
8
  libjpeg-dev \
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Copy requirements and install dependencies
12
+ COPY ./requirements.txt /code/requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
 
 
 
14
 
15
+ # Create non-root user for Hugging Face Spaces
16
  RUN useradd -m -u 1000 user
17
  USER user
18
  ENV HOME=/home/user \
19
  PATH=/home/user/.local/bin:$PATH
20
 
21
+ # Set working directory
22
  WORKDIR $HOME/app
23
+
24
+ # Copy all application files
25
  COPY --chown=user . $HOME/app
26
 
27
+ # Expose port (Hugging Face Spaces uses port 7860)
28
  EXPOSE 7860
29
 
30
+ # Command to run the application
31
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]