File size: 1,072 Bytes
c03605c
 
ee01bda
c03605c
ee01bda
c03605c
 
ee01bda
 
 
c03605c
ee01bda
 
 
 
 
 
7046c8b
c03605c
 
ee01bda
 
 
 
 
 
 
c03605c
ee01bda
 
c03605c
 
ee01bda
bdea1dc
 
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
FROM python:3.13-slim

# system deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl git build-essential \
 && rm -rf /var/lib/apt/lists/*

# install uv and make it globally available
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
    mv /root/.local/bin/uv /usr/local/bin/uv

# use HF persistent writable storage for uv cache
ENV UV_CACHE_DIR=/data/uvcache

# create a non-root user and give it ownership of /app and /data
RUN useradd -m -u 1000 appuser && mkdir -p /app /data/uvcache && \
    chown -R appuser:appuser /app /data

WORKDIR /app

# copy code as appuser so files are writable at runtime
COPY --chown=appuser:appuser . /app

USER appuser

# install deps into project venv from uv.lock (fast/reproducible)
RUN uv --version && uv sync --frozen

# Spaces provides $PORT; default to 7860 for local runs
ENV PORT=7860
EXPOSE 7860

# start Chainlit
# replace the previous CMD with this
CMD ["bash", "-lc", "export CHAINLIT_PORT=${PORT:-7860}; uv run chainlit run src/study_chatbot/app.py --host 0.0.0.0 --port ${PORT:-7860}"]