AurelioAguirre commited on
Commit
8af549e
·
1 Parent(s): 21a14e0

Trying again

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -37
Dockerfile CHANGED
@@ -1,45 +1,19 @@
1
- # Use Python 3.10 slim image as base
2
- FROM python:3.10-slim
3
 
4
- # First: System-level operations that require root
5
- RUN apt-get update && apt-get install -y \
6
- bash \
7
- wget \
8
- git \
9
- git-lfs \
10
- && rm -rf /var/lib/apt/lists/*
11
 
12
- # Second: Create user and set up directories
13
- RUN useradd -m -u 1000 user && \
14
- mkdir -p /app/logs /app/.cache /app/models && \
15
- chmod 777 /app/logs /app/.cache /app/models && \
16
- chown -R user:user /app
17
 
18
- # Third: Switch context to user
19
- USER user
20
-
21
- # Fourth: Set up environment for user
22
- ENV HOME=/home/user \
23
- PATH=/home/user/.local/bin:$PATH
24
-
25
- # Fifth: Set working directory
26
- WORKDIR $HOME/app
27
-
28
- # Rest of the Dockerfile continues with user-level operations
29
- COPY --chown=user requirements.txt .
30
-
31
- RUN pip install --no-cache-dir --upgrade pip && \
32
- pip install --no-cache-dir -r requirements.txt
33
 
 
34
  COPY --chown=user main $HOME/app/main
35
  COPY --chown=user utils $HOME/app/utils
36
 
37
- ENV PYTHONPATH=$HOME/app/main
38
- ENV HF_HOME=$HOME/app/.cache
39
-
40
- RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
41
- export HF_TOKEN=$(cat /run/secrets/HF_TOKEN)
42
-
43
- EXPOSE 7680
44
 
45
- CMD ["python", "-m", "main.app"]
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
 
4
+ FROM python:3.10
 
 
 
 
 
 
5
 
6
+ # The two following lines are requirements for the Dev Mode to be functional
7
+ # Learn more about the Dev Mode at https://huggingface.co/dev-mode-explorers
8
+ RUN useradd -m -u 1000 user
9
+ WORKDIR /app
 
10
 
11
+ COPY --chown=user ./requirements.txt requirements.txt
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ COPY --chown=user . /app
15
  COPY --chown=user main $HOME/app/main
16
  COPY --chown=user utils $HOME/app/utils
17
 
18
+ CMD ["uvicorn", "main.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
19