Prasanta4 commited on
Commit
d7c7d11
·
verified ·
1 Parent(s): 9665733

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +30 -31
dockerfile CHANGED
@@ -1,32 +1,31 @@
1
- FROM python:3.9
2
-
3
- WORKDIR /code
4
-
5
- # Install system dependencies for pillow
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 and install requirements first for caching
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
16
- RUN useradd user
17
- USER user
18
- ENV HOME=/home/user \
19
- PATH=/home/user/.local/bin:$PATH
20
-
21
- # Set working directory for app
22
- WORKDIR $HOME/app
23
-
24
- # Copy application files with correct ownership
25
- COPY --chown=user ./app.py $HOME/app/app.py
26
- COPY --chown=user ./model.py $HOME/app/model.py
27
- COPY --chown=user ./GB_stu_mob.pth $HOME/app/GB_stu_mob.pth
28
-
29
- # Expose port
30
- EXPOSE 7860
31
-
32
  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"]