Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +11 -8
Dockerfile
CHANGED
|
@@ -11,27 +11,30 @@ RUN apt-get update && apt-get install -y gnupg curl redis-server && \
|
|
| 11 |
apt-get update && \
|
| 12 |
apt-get install -y mongodb-org && \
|
| 13 |
rm -rf /var/lib/apt/lists/*
|
| 14 |
-
|
| 15 |
-
# 2. Create data directories and set permissions for Hugging Face
|
| 16 |
RUN mkdir -p /data/db /var/lib/redis /var/lib/overleaf /var/log/overleaf && \
|
| 17 |
chmod -R 777 /data/db /var/lib/redis /var/lib/overleaf /var/log/overleaf
|
| 18 |
|
| 19 |
-
# 3.
|
| 20 |
ENV OVERLEAF_PORT=7860
|
| 21 |
ENV OVERLEAF_LISTEN_IP=0.0.0.0
|
| 22 |
-
ENV OVERLEAF_MONGO_URL=mongodb://127.0.0.1:27017/overleaf
|
| 23 |
ENV OVERLEAF_REDIS_HOST=127.0.0.1
|
| 24 |
ENV OVERLEAF_REDIS_PORT=6379
|
| 25 |
|
| 26 |
-
# 4.
|
| 27 |
RUN echo '#!/bin/bash\n\
|
| 28 |
redis-server --daemonize yes\n\
|
| 29 |
-
# Start MongoDB
|
| 30 |
-
mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db --bind_ip 127.0.0.1\n\
|
| 31 |
sleep 5\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
exec /sbin/my_init\n\
|
| 33 |
' > /entrypoint.sh && chmod +x /entrypoint.sh
|
| 34 |
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
| 11 |
apt-get update && \
|
| 12 |
apt-get install -y mongodb-org && \
|
| 13 |
rm -rf /var/lib/apt/lists/*
|
| 14 |
+
# 2. Permissions for Hugging Face
|
|
|
|
| 15 |
RUN mkdir -p /data/db /var/lib/redis /var/lib/overleaf /var/log/overleaf && \
|
| 16 |
chmod -R 777 /data/db /var/lib/redis /var/lib/overleaf /var/log/overleaf
|
| 17 |
|
| 18 |
+
# 3. Environment Variables (Note the ?replicaSet=overleaf suffix)
|
| 19 |
ENV OVERLEAF_PORT=7860
|
| 20 |
ENV OVERLEAF_LISTEN_IP=0.0.0.0
|
| 21 |
+
ENV OVERLEAF_MONGO_URL=mongodb://127.0.0.1:27017/overleaf?replicaSet=overleaf
|
| 22 |
ENV OVERLEAF_REDIS_HOST=127.0.0.1
|
| 23 |
ENV OVERLEAF_REDIS_PORT=6379
|
| 24 |
|
| 25 |
+
# 4. Updated Entrypoint to handle Replica Set initialization
|
| 26 |
RUN echo '#!/bin/bash\n\
|
| 27 |
redis-server --daemonize yes\n\
|
| 28 |
+
# Start MongoDB with replica set name "overleaf"\n\
|
| 29 |
+
mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db --bind_ip 127.0.0.1 --replSet overleaf\n\
|
| 30 |
sleep 5\n\
|
| 31 |
+
# Initialize the replica set (only needs to run once, but safe to repeat)\n\
|
| 32 |
+
mongosh --eval "try { rs.initiate() } catch (e) { print(\"Already initiated\") }"\n\
|
| 33 |
+
sleep 2\n\
|
| 34 |
+
# Start Overleaf\n\
|
| 35 |
exec /sbin/my_init\n\
|
| 36 |
' > /entrypoint.sh && chmod +x /entrypoint.sh
|
| 37 |
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
+
ENTRYPOINT ["/entrypoint.sh"]
|