File size: 1,591 Bytes
c2c9cd5
60e068a
 
3090e8d
c2c9cd5
60e068a
460c10c
 
 
 
60e068a
460c10c
60e068a
460c10c
c2c9cd5
460c10c
 
60e068a
 
 
460c10c
 
60e068a
c2c9cd5
460c10c
3090e8d
460c10c
3090e8d
c2c9cd5
460c10c
60e068a
460c10c
7453020
 
460c10c
60e068a
c02ec13
c2c9cd5
60e068a
460c10c
 
 
 
 
 
3090e8d
460c10c
3090e8d
6d6e124
7f3f931
3090e8d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ====================================================================
# Dockerfile for Hugging Face Space (Docker runtime)
# Nginx (7860) -> Uvicorn (8000), fix: nginx not found
# ORIGINAL VERSION - RELIES ON HF SECRETS
# ====================================================================

FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1

# Install Nginx + tini (as init)
RUN apt-get update && apt-get install -y --no-install-recommends \
      nginx ca-certificates bash curl tini \
    && rm -rf /var/lib/apt/lists/*

# 🔧 关键修正:把 /usr/sbin 加进 PATH,避免 "nginx: not found"
ENV PATH="/usr/sbin:/sbin:${PATH}"

WORKDIR /app

# Python deps from upstream repo
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# App code (upstream files) — we don't modify them
COPY . .

# Non-root user & perms for Nginx runtime paths
RUN useradd --create-home --shell /bin/bash appuser && \
    mkdir -p /var/lib/nginx /var/cache/nginx /run/nginx /tmp/nginx && \
    chown -R appuser:appuser /app /var/lib/nginx /var/cache/nginx /var/log/nginx /run/nginx /tmp/nginx

# Use your provided nginx.conf (listens 7860, logs/pid in /tmp, user appuser)
COPY nginx.conf /etc/nginx/nginx.conf

# External port
ENV PORT=7860
EXPOSE 7860

USER appuser
ENTRYPOINT ["/usr/bin/tini","--"]

# 🔧 关键修正:使用绝对路径启动 Nginx
CMD bash -lc "\
  uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4 & \
  exec /usr/sbin/nginx -g 'daemon off;' \
"