PunchNFIT commited on
Commit
7a27450
·
1 Parent(s): 6cf2811

Add HF_HOME and finalize non-root Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -13
Dockerfile CHANGED
@@ -1,28 +1,30 @@
1
  FROM python:3.10-slim
2
 
3
-
4
- # Add required system tools for Hugging Face Dev Mode
5
  RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/*
6
 
7
- # Preconfigure Git globally (system-wide to avoid permission issues)
8
  RUN git config --system user.email "366degrees@users.noreply.huggingface.co" && \
9
  git config --system user.name "366degrees"
10
 
11
-
12
- # Create and switch to /app
13
  WORKDIR /app
 
 
14
 
15
- # Copy all repo files into /app
16
- ADD . /app
17
-
18
- # Install dependencies
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # Expose Hugging Face port
 
 
 
 
22
  EXPOSE 7860
 
23
 
24
- # Environment variables for HF cache
25
- ENV HF_HOME=/tmp/huggingface
26
 
27
- # Use Gunicorn (production WSGI server)
28
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "api_inference:app"]
 
1
  FROM python:3.10-slim
2
 
3
+ # 1) System tools for HF Dev Mode
 
4
  RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/*
5
 
6
+ # 2) Preconfigure Git (system-wide to avoid permission issues)
7
  RUN git config --system user.email "366degrees@users.noreply.huggingface.co" && \
8
  git config --system user.name "366degrees"
9
 
10
+ # 3) Create app dir, copy code, set owner
 
11
  WORKDIR /app
12
+ COPY . /app
13
+ RUN useradd -m appuser && chown -R appuser:appuser /app
14
 
15
+ # 4) Python deps
 
 
 
16
  RUN pip install --no-cache-dir -r requirements.txt
17
 
18
+ # 5) Hugging Face cache (writeable in containers)
19
+ ENV HF_HOME=/tmp/huggingface
20
+ RUN mkdir -p /tmp/huggingface
21
+
22
+ # 6) Port + Dev Mode gitconfig fix
23
  EXPOSE 7860
24
+ RUN touch /.gitconfig && chmod 666 /.gitconfig
25
 
26
+ # 7) Switch to non-root for runtime
27
+ USER appuser
28
 
29
+ # 8) Start server (Gunicorn)
30
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "api_inference:app"]