FROM timescale/timescaledb-ha:pg17 USER root # Install Python 3, pip, and venv RUN apt-get update && \ apt-get install -y python3 python3-pip python3-venv curl nginx && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Setup directories for Hugging Face Spaces (UID 1000) # HF Persistent Storage is mounted at /data if enabled. RUN mkdir -p /data/postgres /var/lib/postgresql/data /app /var/log/nginx /var/lib/nginx /etc/nginx && \ chown -R 1000:1000 /data /var/lib/postgresql/data /var/run/postgresql /app /var/log/nginx /var/lib/nginx /etc/nginx # Switch to HF user USER 1000 WORKDIR /app # Create virtual environment and install dependencies RUN python3 -m venv /app/venv ENV PATH="/app/venv/bin:$PATH" COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt # Copy Nginx config COPY nginx.conf /etc/nginx/nginx.conf # Postgres variables ENV POSTGRES_PASSWORD=password ENV PGDATA=/data/postgres # Copy initialization SQL COPY init.sql /docker-entrypoint-initdb.d/ # Copy application code COPY app.py run.sh ingest_worker.py api.py /app/ # Expose port 7860 (Hugging Face default) EXPOSE 7860 # Execute the supervisor script CMD ["bash", "/app/run.sh"]