FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ git git-lfs curl python3 python3-pip \ && pip3 install --no-cache-dir pyyaml \ && rm -rf /var/lib/apt/lists/* # Install ClickHouse static binary RUN curl https://clickhouse.com/ | sh && \ mv clickhouse /usr/local/bin/ && \ chmod +x /usr/local/bin/clickhouse # Install yq — YAML parser for bash (used by refresh_sources.sh) RUN curl -fsSL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \ -o /usr/local/bin/yq && \ chmod +x /usr/local/bin/yq WORKDIR /app COPY . . # Make scripts executable RUN chmod +x init_clickhouse.sh refresh_sources.sh # Create all directories ClickHouse needs — writable by uid 1000 (HF default user) RUN mkdir -p /app/ch/data /app/ch/tmp /app/ch/user_files /app/ch/format_schemas \ /app/ch/access /app/ch/log /app/data && \ chmod -R 777 /app # HF Spaces only exposes this port — gateway sits here EXPOSE 7860 CMD ["bash", "init_clickhouse.sh"]