WISE_Energy / Dockerfile
ahanbose's picture
Update Dockerfile
2b42f8b verified
Raw
History Blame Contribute Delete
1.29 kB
# Using 3.12-slim is safer as many AI wheels for 3.13 are still unstable
FROM python:3.12-slim
# 1. Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# 2. Install essential system libraries
# libgomp1 is required by faiss-cpu
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# 3. Create the mandatory HF non-root user
RUN useradd -m -u 1000 user
USER user
WORKDIR $HOME/app
# 4. Install requirements (requirements.txt is at repo root)
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 5. Copy app files from src/
COPY --chown=user src/ .
# 6. Create persistent data directories
RUN mkdir -p data/faiss_index data/uploads
# 7. Expose the CORRECT Hugging Face port
EXPOSE 7860
# 8. Entrypoint with Port 7860 and XSRF fixes
ENTRYPOINT ["streamlit", "run", "app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.enableXsrfProtection=false", \
"--server.enableCORS=false", \
"--server.headless=true", \
"--server.fileWatcherType=none", \
"--browser.gatherUsageStats=false"]