Update Dockerfile
Browse files- Dockerfile +53 -8
Dockerfile
CHANGED
|
@@ -1,11 +1,56 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
RUN
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Working Dockerfile for Perplexica with Authentication and Port Fix
|
| 2 |
+
FROM itzcrazykns1337/perplexica:latest
|
| 3 |
|
| 4 |
+
# Install curl for health checks
|
| 5 |
+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
+
# Create data directory
|
| 8 |
+
RUN mkdir -p /home/perplexica/data && chmod 777 /home/perplexica/data
|
| 9 |
|
| 10 |
+
# HuggingFace Spaces configuration
|
| 11 |
+
ENV PORT=7860
|
| 12 |
+
ENV HOST=0.0.0.0
|
| 13 |
+
ENV NODE_ENV=production
|
| 14 |
+
|
| 15 |
+
# Create startup script that properly handles authentication
|
| 16 |
+
RUN echo '#!/bin/bash' > /start.sh && \
|
| 17 |
+
echo 'echo "Starting Perplexica with authentication on port 7860..."' >> /start.sh && \
|
| 18 |
+
echo '' >> /start.sh && \
|
| 19 |
+
echo '# Get credentials from HuggingFace secrets' >> /start.sh && \
|
| 20 |
+
echo 'AUTH_USERNAME=${AUTH_USERNAME:-admin}' >> /start.sh && \
|
| 21 |
+
echo 'AUTH_PASSWORD=${AUTH_PASSWORD:-changeme123}' >> /start.sh && \
|
| 22 |
+
echo 'echo "Authentication configured for user: $AUTH_USERNAME"' >> /start.sh && \
|
| 23 |
+
echo '' >> /start.sh && \
|
| 24 |
+
echo '# Create config directory if it does not exist' >> /start.sh && \
|
| 25 |
+
echo 'mkdir -p /home/perplexica/data' >> /start.sh && \
|
| 26 |
+
echo '' >> /start.sh && \
|
| 27 |
+
echo '# Create config.toml line by line to avoid heredoc issues' >> /start.sh && \
|
| 28 |
+
echo 'echo "[GENERAL]" > /home/perplexica/config.toml' >> /start.sh && \
|
| 29 |
+
echo 'echo "PORT = 7860" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 30 |
+
echo 'echo "SIMILARITY_MEASURE = \"cosine\"" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 31 |
+
echo 'echo "AUTHENTICATION = true" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 32 |
+
echo 'echo "" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 33 |
+
echo 'echo "[AUTHENTICATION]" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 34 |
+
echo 'echo "USERNAME = \"$AUTH_USERNAME\"" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 35 |
+
echo 'echo "PASSWORD = \"$AUTH_PASSWORD\"" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 36 |
+
echo 'echo "" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 37 |
+
echo 'echo "[API_ENDPOINTS]" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 38 |
+
echo 'echo "SEARXNG = \"http://localhost:8080\"" >> /home/perplexica/config.toml' >> /start.sh && \
|
| 39 |
+
echo '' >> /start.sh && \
|
| 40 |
+
echo 'cp /home/perplexica/config.toml /home/perplexica/data/config.toml' >> /start.sh && \
|
| 41 |
+
echo 'chmod 644 /home/perplexica/config.toml /home/perplexica/data/config.toml' >> /start.sh && \
|
| 42 |
+
echo 'echo "Configuration completed. Starting Perplexica..."' >> /start.sh && \
|
| 43 |
+
echo '' >> /start.sh && \
|
| 44 |
+
echo '# Start the application' >> /start.sh && \
|
| 45 |
+
echo 'exec "$@"' >> /start.sh && \
|
| 46 |
+
chmod +x /start.sh
|
| 47 |
+
|
| 48 |
+
# Health check
|
| 49 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 50 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 51 |
+
|
| 52 |
+
# Expose port 7860 (required by HuggingFace Spaces)
|
| 53 |
+
EXPOSE 7860
|
| 54 |
+
|
| 55 |
+
# Use the start script as entrypoint to configure authentication
|
| 56 |
+
ENTRYPOINT ["/start.sh"]
|