JSCPPProgrammer commited on
Commit
1fd52ef
·
verified ·
1 Parent(s): f305c9e

PID1 python docker_entry.py; normalize entrypoint BOM/CRLF in build

Browse files
Files changed (1) hide show
  1. docker_entry.py +44 -0
docker_entry.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Space (Docker) — GenSearcher + FireRed
2
+ # Requires GPU. For multi-GPU full-local mode, set START_VLLM_*=1 and CUDA device envs in README.
3
+
4
+ FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
5
+
6
+ ENV DEBIAN_FRONTEND=noninteractive
7
+ RUN apt-get update && apt-get install -y --no-install-recommends \
8
+ curl \
9
+ git \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ WORKDIR /app
13
+
14
+ COPY vendor/rllm /app/vendor/rllm
15
+ COPY requirements.txt /app/requirements.txt
16
+ COPY app.py space_gen.py space_health.py /app/
17
+ COPY services /app/services
18
+ COPY scripts /app/scripts
19
+ COPY docker_entry.py /app/docker_entry.py
20
+ # Strip BOM + all CR so bash never sees \r (avoids "exec format error" / stray $'\r' errors).
21
+ RUN python3 -c "import pathlib; p=pathlib.Path('/app/scripts/entrypoint.sh'); b=p.read_bytes(); b=b.lstrip(b'\\xef\\xbb\\xbf'); b=b.replace(b'\\r\\n', b'\\n').replace(b'\\r', b''); p.write_bytes(b)" \
22
+ && chmod +x /app/scripts/entrypoint.sh
23
+
24
+ ENV PYTHONPATH=/app/vendor/rllm
25
+ ENV GRADIO_SERVER_PORT=7860
26
+ # HF Spaces / minimal images often have uid 1000 with no /etc/passwd entry; PyTorch Inductor calls
27
+ # getpass.getuser() and crashes with KeyError. USER/LOGNAME short-circuit getuser(); cache dirs avoid $HOME issues.
28
+ ENV USER=huggingface
29
+ ENV LOGNAME=huggingface
30
+ ENV TORCHINDUCTOR_CACHE_DIR=/tmp/torch_inductor_cache
31
+ ENV TRITON_CACHE_DIR=/tmp/triton_cache
32
+
33
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
34
+ && pip install --no-cache-dir -e /app/vendor/rllm \
35
+ && pip install --no-cache-dir -r /app/requirements.txt
36
+
37
+ # Optional: local vLLM inside the image (large). Disable with build-arg if you only use external APIs.
38
+ ARG INSTALL_VLLM=1
39
+ RUN if [ "$INSTALL_VLLM" = "1" ]; then pip install --no-cache-dir "vllm>=0.6.3"; fi
40
+
41
+ EXPOSE 7860
42
+
43
+ # Python as PID 1: kernel never execve's entrypoint.sh directly (fixes HF "exec format error" on CRLF/BOM).
44
+ CMD ["python", "/app/docker_entry.py"]