smarttrip_ai / Dockerfile
swaraj
fix: remove -e . from requirements, copy setup.py before pip install in Docker
bb8f4b1
Raw
History Blame Contribute Delete
2.48 kB
# ─────────────────────────────────────────────────────────────────────────────
# SmartTrip AI β€” Dockerfile for Hugging Face Spaces
#
# Build locally:
# docker build -t smarttrip-ai .
# docker run -p 7860:7860 --env-file .env smarttrip-ai
#
# Hugging Face Spaces automatically detects this file and builds the image.
# Set all API keys under Space β†’ Settings β†’ Variables and secrets (not here).
# ─────────────────────────────────────────────────────────────────────────────
FROM python:3.10-slim
# System dependencies required by some Python packages (e.g. Pillow, lxml)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Non-root user recommended by Hugging Face Spaces
RUN useradd -m -u 1000 appuser
WORKDIR /app
# ── Install Python dependencies ───────────────────────────────────────────────
# Copy requirements + setup files first so Docker can cache this layer
COPY --chown=appuser:appuser requirements.txt setup.py ./
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# ── Copy application source ───────────────────────────────────────────────────
COPY --chown=appuser:appuser . .
# Create writable runtime directories inside the container
# (SQLite DB goes to data/, logs go to logs/)
RUN mkdir -p data logs \
&& chown -R appuser:appuser data logs
USER appuser
# ── Expose port expected by Hugging Face Spaces ───────────────────────────────
EXPOSE 7860
# ── Run the Streamlit app ─────────────────────────────────────────────────────
CMD ["streamlit", "run", "streamlit_app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.headless=true", \
"--browser.gatherUsageStats=false"]