Spaces:
Runtime error
Runtime error
| FROM shantanupatil01/overleaf-extended:latest | |
| USER root | |
| # 1. Install dependencies, add MongoDB 8.0 GPG key and Repository | |
| RUN apt-get update && apt-get install -y gnupg curl redis-server && \ | |
| curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \ | |
| gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg && \ | |
| echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | \ | |
| tee /etc/apt/sources.list.d/mongodb-org-8.0.list && \ | |
| apt-get update && \ | |
| apt-get install -y mongodb-org && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 2. Permissions for Hugging Face | |
| RUN mkdir -p /data/db /var/lib/redis /var/lib/overleaf /var/log/overleaf && \ | |
| chmod -R 777 /data/db /var/lib/redis /var/lib/overleaf /var/log/overleaf | |
| # 3. Environment Variables (Note the ?replicaSet=overleaf suffix) | |
| ENV OVERLEAF_PORT=7860 | |
| ENV OVERLEAF_LISTEN_IP=0.0.0.0 | |
| ENV OVERLEAF_MONGO_URL=mongodb://127.0.0.1:27017/overleaf?replicaSet=overleaf | |
| ENV OVERLEAF_REDIS_HOST=127.0.0.1 | |
| ENV OVERLEAF_REDIS_PORT=6379 | |
| # 4. Updated Entrypoint to handle Replica Set initialization | |
| RUN echo '#!/bin/bash\n\ | |
| redis-server --daemonize yes\n\ | |
| # Start MongoDB with replica set name "overleaf"\n\ | |
| mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db --bind_ip 127.0.0.1 --replSet overleaf\n\ | |
| sleep 5\n\ | |
| # Initialize the replica set (only needs to run once, but safe to repeat)\n\ | |
| mongosh --eval "try { rs.initiate() } catch (e) { print(\"Already initiated\") }"\n\ | |
| sleep 2\n\ | |
| # Start Overleaf\n\ | |
| exec /sbin/my_init\n\ | |
| ' > /entrypoint.sh && chmod +x /entrypoint.sh | |
| EXPOSE 7860 | |
| ENTRYPOINT ["/entrypoint.sh"] |