File size: 1,690 Bytes
91f1417
251402d
b6b9470
7fb96cf
be47e8f
 
 
 
 
 
 
 
 
e8b828d
be47e8f
 
dce0328
e8b828d
b6b9470
 
e8b828d
b6b9470
 
dce0328
e8b828d
b6b9470
 
e8b828d
 
b6b9470
e8b828d
 
 
 
b6b9470
 
dce0328
91f1417
b6b9470
e8b828d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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"]