nxdev-org commited on
Commit
e928d09
·
1 Parent(s): 251402d

update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +51 -52
Dockerfile CHANGED
@@ -1,60 +1,59 @@
1
  # HuggingFace Spaces Dockerfile for Overleaf with Japanese LaTeX
2
  #
3
- # Self-contained Overleaf with:
4
- # - Full TeX Live 2025 (Japanese support)
5
- # - MongoDB 8.0
6
- # - Redis
7
- # - All data in /data (persisted by HF Spaces)
 
8
 
9
  FROM fifof16/sharelatex-with-texlive-full:latest
10
 
11
- USER root
 
 
 
12
 
13
- # Update and install MongoDB
14
- RUN apt-get update && apt-get install -y \
15
- wget \
16
- gnupg \
17
- && rm -rf /var/lib/apt/lists/*
18
 
19
- RUN wget -qO - https://www.mongodb.org/static/pgp/server-8.0.asc | apt-key add - \
20
- && echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list \
21
- && apt-get update \
22
- && apt-get install -y mongodb-org \
23
- && rm -rf /var/lib/apt-lists/*
24
 
25
- # Create directories for data persistence
26
- RUN mkdir -p /data/{mongo,redis,overleaf,git-bridge} \
27
- /var/lib/overleaf/data/{uploads,compiles,history,tags} \
28
- && chmod -R 777 /data /var/lib/overleaf
29
-
30
- # Create startup script
31
- RUN echo '#!/bin/bash' > /start-hf.sh \
32
- && echo 'set -e' >> /start-hf.sh \
33
- && echo '' >> /start-hf.sh \
34
- && echo 'echo "Starting MongoDB..."' >> /start-hf.sh \
35
- && echo 'mongod --dbpath /data/mongo --bind_ip 127.0.0.1 --replSet overleaf --fork --logpath /var/log/mongodb.log' >> /start-hf.sh \
36
- && echo 'sleep 5' >> /start-hf.sh \
37
- && echo 'mongosh --eval "rs.initiate({_id: \"overleaf\", members: [{_id: 0, host: \"127.0.0.1:27017\"}]})" 2>/dev/null || true' >> /start-hf.sh \
38
- && echo '' >> /start-hf.sh \
39
- && echo 'echo "Starting Redis..."' >> /start-hf.sh \
40
- && echo 'redis-server --daemonize yes --dir /data/redis' >> /start-hf.sh \
41
- && echo '' >> /start-hf.sh \
42
- && echo 'echo "Starting Overleaf..."' >> /start-hf.sh \
43
- && echo 'export OVERLEAF_MONGO_URL="mongodb://127.0.0.1:27017/sharelatex"' >> /start-hf.sh \
44
- && echo 'export OVERLEAF_REDIS_HOST="127.0.0.1"' >> /start-hf.sh \
45
- && echo 'export OVERLEAF_REDIS_PORT="6379"' >> /start-hf.sh \
46
- && echo 'export OVERLEAF_DATA_PATH="/data/overleaf"' >> /start-hf.sh \
47
- && echo 'exec /sbin/my_init' >> /start-hf.sh \
48
- && chmod +x /start-hf.sh
49
-
50
- # Bind Overleaf to all interfaces
51
- RUN sed -i 's|OVERLEAF_LISTEN_IP=.*|OVERLEAF_LISTEN_IP=0.0.0.0|' /etc/overleaf/env.sh || true
52
-
53
- EXPOSE 80
54
-
55
- HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=3 \
56
- CMD curl -f http://localhost/ || exit 1
57
-
58
- USER 1000
59
-
60
- CMD ["/start-hf.sh"]
 
1
  # HuggingFace Spaces Dockerfile for Overleaf with Japanese LaTeX
2
  #
3
+ # Features:
4
+ # - Full TeX Live 2025 with Japanese support
5
+ # - MongoDB 8.0 embedded
6
+ # - Redis embedded
7
+ # - Port 7860 (HF Spaces default)
8
+ # - Data persistence in /data
9
 
10
  FROM fifof16/sharelatex-with-texlive-full:latest
11
 
12
+ # Create directories first (as root)
13
+ RUN mkdir -p /data/{mongo,redis,overleaf,git-bridge} \
14
+ /var/log/{mongodb,redis} \
15
+ && chmod -R 777 /data /var/log
16
 
17
+ # Fix all permissions that might cause issues
18
+ RUN chmod -R 777 /etc /etc/container_environment 2>/dev/null || true
 
 
 
19
 
20
+ # Create a wrapper script that properly initializes everything
21
+ RUN cat > /init.sh << 'EOF'
22
+ #!/bin/bash
23
+ set -e
 
24
 
25
+ # Fix permissions first
26
+ chmod 755 /etc
27
+ chmod 755 /etc/container_environment 2>/dev/null || true
28
+ chmod 644 /etc/container_environment/*.sh 2>/dev/null || true
29
+ chmod 644 /etc/overleaf/env.sh 2>/dev/null || true
30
+ chmod 755 /etc/my_init.d/ 2>/dev/null || true
31
+
32
+ # Source environment
33
+ source /etc/overleaf/env.sh 2>/dev/null || true
34
+ source /etc/container_environment/*.sh 2>/dev/null || true
35
+
36
+ # Override port to 7860
37
+ export OVERLEAF_PORT=7860
38
+
39
+ # Start MongoDB
40
+ echo "Starting MongoDB..."
41
+ mongod --dbpath /data/mongo --bind_ip 127.0.0.1 --replSet overleaf --fork --logpath /var/log/mongodb/mongodb.log
42
+ sleep 5
43
+
44
+ # Initialize replica set
45
+ mongosh --quiet --eval "try { rs.initiate({_id: 'overleaf', members: [{_id: 0, host: '127.0.0.1:27017'}]}); } catch(e) { }" 2>/dev/null || true
46
+
47
+ # Start Redis
48
+ echo "Starting Redis..."
49
+ redis-server --daemonize yes --dir /data/redis --logfile /var/log/redis/redis.log 2>/dev/null || true
50
+
51
+ echo "Starting Overleaf..."
52
+ exec /sbin/my_init
53
+ EOF
54
+
55
+ RUN chmod +x /init.sh
56
+
57
+ EXPOSE 7860
58
+
59
+ CMD ["/init.sh"]