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

add Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +60 -0
Dockerfile ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]