Spaces:
Sleeping
Sleeping
Download Dockerfile.huggingface from edichat/edi.chat.test: direct link, hf CLI and curl.
- Browser
- Download file 2.29 kB
-
https://huggingface.co/spaces/edichat/edi.chat.test/resolve/main/Dockerfile.huggingface
- Command line
-
hf download hf://spaces/edichat/edi.chat.test/Dockerfile.huggingface
-
curl -L -o Dockerfile.huggingface https://huggingface.co/spaces/edichat/edi.chat.test/resolve/main/Dockerfile.huggingface
2.29 kB
| # edi.chat with Ollama on Hugging Face Spaces | |
| FROM node:20-slim | |
| # Create non-root user for security | |
| RUN useradd -m -u 1000 user | |
| # Set working directory | |
| WORKDIR /home/user/app | |
| # Install system dependencies including curl for Ollama | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| curl \ | |
| wget \ | |
| ca-certificates \ | |
| gpg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Ollama | |
| RUN curl -fsSL https://ollama.com/install.sh | sh | |
| # Copy package files first for better caching | |
| COPY --chown=user package*.json ./ | |
| # Install dependencies | |
| RUN npm ci --only=production | |
| # Copy application files | |
| COPY --chown=user . ./ | |
| # Create startup script that starts Ollama and the app | |
| RUN echo '#!/bin/bash\n\ | |
| echo "π Starting edi.chat with Ollama on Hugging Face..."\n\ | |
| echo "PORT: ${PORT:-7860}"\n\ | |
| echo ""\n\ | |
| \n\ | |
| # Start Ollama in background\n\ | |
| echo "π€ Starting Ollama server..."\n\ | |
| ollama serve &\n\ | |
| OLLAMA_PID=$!\n\ | |
| \n\ | |
| # Wait for Ollama to be ready\n\ | |
| echo "β³ Waiting for Ollama to start..."\n\ | |
| sleep 10\n\ | |
| \n\ | |
| # Check if Ollama is running\n\ | |
| if curl -s http://localhost:11434/api/tags > /dev/null; then\n\ | |
| echo "β Ollama is running"\n\ | |
| else\n\ | |
| echo "β Ollama failed to start"\n\ | |
| fi\n\ | |
| \n\ | |
| # Pull the default model (lightweight for HF)\n\ | |
| echo "π¦ Pulling AI model..."\n\ | |
| ollama pull tinyllama || echo "β οΈ Failed to pull model, will try at runtime"\n\ | |
| \n\ | |
| echo "π Starting edi.chat application..."\n\ | |
| echo "Environment: ${NODE_ENV:-production}"\n\ | |
| echo "AI Model: ${LOCAL_AI_MODEL:-tinyllama}"\n\ | |
| echo ""\n\ | |
| \n\ | |
| # Start the Node.js application\n\ | |
| exec node server.js' > /home/user/start.sh | |
| RUN chmod +x /home/user/start.sh | |
| # Switch to non-root user | |
| USER user | |
| # Expose port | |
| EXPOSE 7860 | |
| # Set environment variables for Ollama | |
| ENV PORT=7860 | |
| ENV NODE_ENV=production | |
| ENV USE_LOCAL_AI=true | |
| ENV USE_HUGGINGFACE=false | |
| ENV USE_OPENAI=false | |
| ENV LOCAL_AI_URL=http://localhost:11434 | |
| ENV LOCAL_AI_MODEL=tinyllama | |
| ENV NO_DATABASE_BLOCKING=true | |
| ENV JWT_SECRET=hf-spaces-secret-change-in-production | |
| ENV JWT_REFRESH_SECRET=hf-spaces-refresh-secret-change-in-production | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Start the application | |
| CMD ["/home/user/start.sh"] |