Spaces:
Sleeping
Sleeping
ateetvatan
commited on
Commit
ยท
061676c
1
Parent(s):
6b456ee
changes for 8 cpu
Browse files- Dockerfile +15 -16
Dockerfile
CHANGED
@@ -1,40 +1,39 @@
|
|
1 |
-
# Base image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
-
# Create non-root user
|
5 |
RUN useradd -m -u 1000 user
|
6 |
|
7 |
-
# Set
|
8 |
-
ENV HOME=/home/user
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
-
#
|
13 |
WORKDIR $APP_HOME
|
14 |
|
15 |
-
#
|
16 |
USER root
|
17 |
-
|
18 |
-
# Install system dependencies
|
19 |
RUN apt-get update && apt-get install -y \
|
20 |
git curl \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
-
#
|
24 |
COPY --chown=user:user requirements.txt .
|
25 |
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
26 |
|
27 |
-
# Copy app code
|
28 |
COPY --chown=user:user . .
|
29 |
|
30 |
-
# Ensure
|
31 |
RUN mkdir -p $HF_HOME && chown -R user:user $HF_HOME
|
32 |
|
33 |
-
#
|
34 |
USER user
|
35 |
|
36 |
-
# Expose
|
37 |
EXPOSE 7860
|
38 |
|
39 |
-
#
|
40 |
CMD ["python", "app.py"]
|
|
|
1 |
+
# ๐น Base image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# ๐น Create Hugging Face-compliant non-root user
|
5 |
RUN useradd -m -u 1000 user
|
6 |
|
7 |
+
# ๐น Set environment variables
|
8 |
+
ENV HOME=/home/user \
|
9 |
+
APP_HOME=/home/user/app \
|
10 |
+
HF_HOME=/home/user/.hf_home \
|
11 |
+
OMP_NUM_THREADS=8 # โ
Use all 8 vCPUs
|
12 |
|
13 |
+
# ๐น Set working directory
|
14 |
WORKDIR $APP_HOME
|
15 |
|
16 |
+
# ๐น Install system dependencies (root)
|
17 |
USER root
|
|
|
|
|
18 |
RUN apt-get update && apt-get install -y \
|
19 |
git curl \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
+
# ๐น Install Python dependencies
|
23 |
COPY --chown=user:user requirements.txt .
|
24 |
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
25 |
|
26 |
+
# ๐น Copy app code and give ownership to non-root user
|
27 |
COPY --chown=user:user . .
|
28 |
|
29 |
+
# ๐น Ensure HF model cache dir is writable
|
30 |
RUN mkdir -p $HF_HOME && chown -R user:user $HF_HOME
|
31 |
|
32 |
+
# ๐น Switch to non-root user (required by HF Spaces)
|
33 |
USER user
|
34 |
|
35 |
+
# ๐น Expose the FastAPI port
|
36 |
EXPOSE 7860
|
37 |
|
38 |
+
# ๐น Start your app
|
39 |
CMD ["python", "app.py"]
|