nxdev-org commited on
Commit
3a68f6b
·
1 Parent(s): e928d09

update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -48
Dockerfile CHANGED
@@ -1,59 +1,47 @@
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"]
 
 
 
1
  # HuggingFace Spaces Dockerfile for Overleaf with Japanese LaTeX
2
+ #
3
+ # Key: Set correct MongoDB/Redis URLs BEFORE /sbin/my_init runs
 
 
 
 
 
4
 
5
  FROM fifof16/sharelatex-with-texlive-full:latest
6
 
7
+ # Create directories
8
  RUN mkdir -p /data/{mongo,redis,overleaf,git-bridge} \
9
  /var/log/{mongodb,redis} \
10
  && chmod -R 777 /data /var/log
11
 
12
+ # Fix all permissions
13
+ RUN chmod -R 777 /etc 2>/dev/null || true
14
+
15
+ # Remove original check scripts - they use wrong hostnames
16
+ RUN rm -f /etc/my_init.d/500_check_db_access.sh 2>/dev/null || true
17
+ RUN rm -f /etc/my_init.d/500_check_mongo.sh 2>/dev/null || true
18
+
19
+ # Override environment BEFORE my_init runs (this is critical!)
20
+ # The container_environment files are sourced by /sbin/my_init
21
+ RUN mkdir -p /etc/container_environment
22
+ RUN echo "mongodb://127.0.0.1:27017/sharelatex" > /etc/container_environment/OVERLEAF_MONGO_URL
23
+ RUN echo "127.0.0.1" > /etc/container_environment/OVERLEAF_REDIS_HOST
24
+ RUN echo "6379" > /etc/container_environment/OVERLEAF_REDIS_PORT
25
+ RUN echo "0.0.0.0" > /etc/container_environment/OVERLEAF_LISTEN_IP
26
+ RUN echo "7860" > /etc/container_environment/OVERLEAF_PORT
27
+
28
+ RUN chmod 644 /etc/container_environment/OVERLEAF_*
29
+
30
+ # Also update /etc/overleaf/env.sh
31
+ RUN chown root:root /etc/overleaf/env.sh 2>/dev/null || true
32
+ RUN sed -i 's|dockerhost|127.0.0.1|g; s|mongod://|mongodb://127.0.0.1:|g' /etc/overleaf/env.sh 2>/dev/null || true
33
+ RUN echo "OVERLEAF_MONGO_URL=mongodb://127.0.0.1:27017/sharelatex" >> /etc/overleaf/env.sh
34
+ RUN echo "OVERLEAF_REDIS_HOST=127.0.0.1" >> /etc/overleaf/env.sh
35
+ RUN echo "OVERLEAF_REDIS_PORT=6379" >> /etc/overleaf/env.sh
36
+ RUN echo "OVERLEAF_LISTEN_IP=0.0.0.0" >> /etc/overleaf/env.sh
37
+ RUN echo "OVERLEAF_PORT=7860" >> /etc/overleaf/env.sh
38
+ RUN chmod 644 /etc/overleaf/env.sh
39
+
40
+ # Stay as root
41
+ USER root
 
 
 
 
 
 
 
 
 
42
 
43
  EXPOSE 7860
44
 
45
+ # Run my_init directly - it will start MongoDB/Redis from their runit services
46
+ # and use our overridden environment variables
47
+ CMD ["/sbin/my_init"]