| FROM debian:stable-slim | |
| # Container metadata | |
| LABEL maintainer="huggingface-spaces" | |
| LABEL description="Universal HF Docker Template" | |
| # Copy installation scripts | |
| COPY scripts/install/ /tmp/install/ | |
| # Install all services by processing all .sh files in install directory | |
| RUN chmod +x /tmp/install/*.sh | |
| # Install base dependencies first | |
| RUN /tmp/install/base-install.sh | |
| # Install all other services automatically | |
| RUN for script in /tmp/install/*.sh; do \ | |
| if [ "$(basename "$script")" != "base-install.sh" ]; then \ | |
| echo "Running installation script: $(basename "$script")"; \ | |
| "$script"; \ | |
| fi; \ | |
| done | |
| # Clean up installation scripts | |
| RUN rm -rf /tmp/install* | |
| # Create user with UID 1000 for Hugging Face Spaces compatibility | |
| RUN if id -u 1000 >/dev/null 2>&1; then \ | |
| usermod -l user $(id -un 1000) && \ | |
| usermod -d /home/user -m user; \ | |
| else \ | |
| useradd -m -u 1000 user; \ | |
| fi && \ | |
| mkdir -p /home/user/config /home/user/data && \ | |
| chown -R 1000:1000 /home/user | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME | |
| # Create required directories | |
| RUN mkdir -p /home/user/config /home/user/data /home/user/log \ | |
| /home/user/.cache/huggingface /home/user/downloads /home/user/temp | |
| # Copy project structure | |
| COPY --chown=user:user scripts/ /home/user/scripts/ | |
| COPY --chown=user:user configs/ /home/user/config/ | |
| # Make scripts executable | |
| RUN find /home/user/scripts -name "*.sh" -exec chmod +x {} \; | |
| # Default ports: | |
| # 7860 - Legacy HuggingFace Spaces default (kept for compatibility) | |
| EXPOSE 7860 | |
| # Copy main entrypoint script | |
| COPY --chown=user:user docker-entrypoint.sh /home/user/docker-entrypoint.sh | |
| RUN chmod +x /home/user/docker-entrypoint.sh | |
| # Start the universal template | |
| CMD ["/home/user/docker-entrypoint.sh"] |