Spaces:
Runtime error
Runtime error
update Dockerfile
Browse files- Dockerfile +72 -19
Dockerfile
CHANGED
|
@@ -1,6 +1,12 @@
|
|
| 1 |
# HuggingFace Spaces Dockerfile for Overleaf with Japanese LaTeX
|
| 2 |
-
#
|
| 3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
FROM fifof16/sharelatex-with-texlive-full:latest
|
| 6 |
|
|
@@ -12,29 +18,77 @@ RUN mkdir -p /data/{mongo,redis,overleaf,git-bridge} \
|
|
| 12 |
# Fix all permissions
|
| 13 |
RUN chmod -R 777 /etc 2>/dev/null || true
|
| 14 |
|
| 15 |
-
#
|
|
|
|
|
|
|
| 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 |
-
#
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
RUN mkdir -p /etc/container_environment
|
| 22 |
-
RUN
|
| 23 |
-
RUN
|
| 24 |
-
RUN
|
| 25 |
-
RUN
|
| 26 |
-
RUN
|
| 27 |
|
| 28 |
RUN chmod 644 /etc/container_environment/OVERLEAF_*
|
| 29 |
|
| 30 |
# Also update /etc/overleaf/env.sh
|
| 31 |
-
RUN
|
| 32 |
-
RUN
|
| 33 |
-
RUN
|
| 34 |
-
RUN
|
| 35 |
-
RUN
|
| 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
|
|
@@ -42,6 +96,5 @@ USER root
|
|
| 42 |
|
| 43 |
EXPOSE 7860
|
| 44 |
|
| 45 |
-
# Run my_init
|
| 46 |
-
# and use our overridden environment variables
|
| 47 |
CMD ["/sbin/my_init"]
|
|
|
|
| 1 |
# HuggingFace Spaces Dockerfile for Overleaf with Japanese LaTeX
|
| 2 |
+
#
|
| 3 |
+
# FIXED: MongoDB/Redis must start before migrations run
|
| 4 |
+
#
|
| 5 |
+
# Features:
|
| 6 |
+
# - Full TeX Live 2025 with Japanese support
|
| 7 |
+
# - MongoDB 8.0 embedded
|
| 8 |
+
# - Redis embedded
|
| 9 |
+
# - Port 7860
|
| 10 |
|
| 11 |
FROM fifof16/sharelatex-with-texlive-full:latest
|
| 12 |
|
|
|
|
| 18 |
# Fix all permissions
|
| 19 |
RUN chmod -R 777 /etc 2>/dev/null || true
|
| 20 |
|
| 21 |
+
# ============================================
|
| 22 |
+
# STEP 1: REMOVE DEFAULT MONGO CHECK SCRIPTS
|
| 23 |
+
# ============================================
|
| 24 |
RUN rm -f /etc/my_init.d/500_check_db_access.sh 2>/dev/null || true
|
| 25 |
RUN rm -f /etc/my_init.d/500_check_mongo.sh 2>/dev/null || true
|
| 26 |
+
RUN rm -f /etc/runit/mongo 2>/dev/null || true
|
| 27 |
+
RUN rm -f /etc/runit/redis 2>/dev/null || true
|
| 28 |
|
| 29 |
+
# ============================================
|
| 30 |
+
# STEP 2: CREATE CUSTOM INIT SCRIPT EARLY
|
| 31 |
+
# ============================================
|
| 32 |
+
# Run FIRST to start MongoDB before ANYTHING else
|
| 33 |
+
RUN cat > /etc/my_init.d/00_start_services.sh << 'EOFSCRIPT'
|
| 34 |
+
#!/bin/bash
|
| 35 |
+
set -e
|
| 36 |
+
|
| 37 |
+
echo "=== STARTING MONGODB ==="
|
| 38 |
+
if ! pgrep -x mongod > /dev/null 2>&1; then
|
| 39 |
+
mongod --dbpath /data/mongo \
|
| 40 |
+
--bind_ip 127.0.0.1 \
|
| 41 |
+
--replSet overleaf \
|
| 42 |
+
--fork \
|
| 43 |
+
--logpath /var/log/mongodb/mongodb.log \
|
| 44 |
+
--port 27017 \
|
| 45 |
+
--quiet
|
| 46 |
+
|
| 47 |
+
sleep 10
|
| 48 |
+
|
| 49 |
+
echo "=== INITIATING REPLICA SET ==="
|
| 50 |
+
mongosh --quiet --eval "
|
| 51 |
+
try {
|
| 52 |
+
rs.initiate({_id: 'overleaf', members: [{_id: 0, host: '127.0.0.1:27017'}]});
|
| 53 |
+
print('Replica set initiated');
|
| 54 |
+
} catch(e) {
|
| 55 |
+
print('Replica set may already exist: ' + e);
|
| 56 |
+
}
|
| 57 |
+
" 2>&1 || true
|
| 58 |
+
fi
|
| 59 |
+
|
| 60 |
+
echo "=== STARTING REDIS ==="
|
| 61 |
+
if ! pgrep -x redis-server > /dev/null 2>&1; then
|
| 62 |
+
redis-server --daemonize yes \
|
| 63 |
+
--dir /data/redis \
|
| 64 |
+
--port 6379 \
|
| 65 |
+
--bind 127.0.0.1 \
|
| 66 |
+
--logfile /var/log/redis/redis.log 2>/dev/null || true
|
| 67 |
+
fi
|
| 68 |
+
|
| 69 |
+
echo "=== SERVICES STARTED ==="
|
| 70 |
+
EOFSCRIPT
|
| 71 |
+
|
| 72 |
+
RUN chmod +x /etc/my_init.d/00_start_services.sh
|
| 73 |
+
|
| 74 |
+
# ============================================
|
| 75 |
+
# STEP 3: SET ENVIRONMENT (critical for my_init)
|
| 76 |
+
# ============================================
|
| 77 |
RUN mkdir -p /etc/container_environment
|
| 78 |
+
RUN printf "mongodb://127.0.0.1:27017/sharelatex" > /etc/container_environment/OVERLEAF_MONGO_URL
|
| 79 |
+
RUN printf "127.0.0.1" > /etc/container_environment/OVERLEAF_REDIS_HOST
|
| 80 |
+
RUN printf "6379" > /etc/container_environment/OVERLEAF_REDIS_PORT
|
| 81 |
+
RUN printf "0.0.0.0" > /etc/container_environment/OVERLEAF_LISTEN_IP
|
| 82 |
+
RUN printf "7860" > /etc/container_environment/OVERLEAF_PORT
|
| 83 |
|
| 84 |
RUN chmod 644 /etc/container_environment/OVERLEAF_*
|
| 85 |
|
| 86 |
# Also update /etc/overleaf/env.sh
|
| 87 |
+
RUN printf "OVERLEAF_MONGO_URL=mongodb://127.0.0.1:27017/sharelatex\n" >> /etc/overleaf/env.sh
|
| 88 |
+
RUN printf "OVERLEAF_REDIS_HOST=127.0.0.1\n" >> /etc/overleaf/env.sh
|
| 89 |
+
RUN printf "OVERLEAF_REDIS_PORT=6379\n" >> /etc/overleaf/env.sh
|
| 90 |
+
RUN printf "OVERLEAF_LISTEN_IP=0.0.0.0\n" >> /etc/overleaf/env.sh
|
| 91 |
+
RUN printf "OVERLEAF_PORT=7860\n" >> /etc/overleaf/env.sh
|
|
|
|
|
|
|
| 92 |
RUN chmod 644 /etc/overleaf/env.sh
|
| 93 |
|
| 94 |
# Stay as root
|
|
|
|
| 96 |
|
| 97 |
EXPOSE 7860
|
| 98 |
|
| 99 |
+
# Run my_init - it will run 00_start_services.sh BEFORE migrations
|
|
|
|
| 100 |
CMD ["/sbin/my_init"]
|