Update Dockerfile
Browse files- Dockerfile +16 -28
Dockerfile
CHANGED
@@ -1,36 +1,24 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
# 1) Prevent .pyc and buffer stdout
|
4 |
-
ENV PYTHONDONTWRITEBYTECODE=1 \
|
5 |
-
PYTHONUNBUFFERED=1 \
|
6 |
-
# 2) Redirect HF & transformers cache to a writable folder
|
7 |
-
XDG_CACHE_HOME=/app/.cache \
|
8 |
-
HF_HOME=/app/.cache/huggingface
|
9 |
-
|
10 |
WORKDIR /app
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
libgl1-mesa-glx \
|
16 |
-
&& rm -rf /var/lib/apt/lists/* \
|
17 |
-
# 4) Make cache dirs and set perms
|
18 |
-
&& mkdir -p /app/.cache/huggingface \
|
19 |
-
&& chmod -R 777 /app/.cache
|
20 |
-
|
21 |
-
# 5) Copy & install python deps
|
22 |
-
COPY requirements.txt .
|
23 |
-
RUN pip install --upgrade pip \
|
24 |
-
&& pip install --no-cache-dir -r requirements.txt
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
SentenceTransformer("sentence-transformers/all-mpnet-base-v2")
|
34 |
-
EOF
|
35 |
|
36 |
-
|
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
WORKDIR /app
|
4 |
|
5 |
+
# Copy and install requirements
|
6 |
+
COPY requirements.txt /app/requirements.txt
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# Set up a new non-root user
|
10 |
+
RUN useradd -m -u 1000 user
|
11 |
+
USER user
|
12 |
+
ENV HOME=/home/user
|
13 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
14 |
|
15 |
+
# Create a cache directory and set environment variable
|
16 |
+
RUN mkdir -p /home/user/.cache && chown -R user:user /home/user/.cache
|
17 |
+
ENV HF_HOME=/home/user/.cache
|
18 |
|
19 |
+
# Set working directory to the user's app directory
|
20 |
+
WORKDIR $HOME/app
|
21 |
+
COPY --chown=user . $HOME/app
|
|
|
|
|
22 |
|
23 |
+
EXPOSE 7860
|
24 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|