Spaces:
Running
Running
File size: 3,132 Bytes
394952a 2db073d 394952a 2db073d 394952a |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# 基于教程中提到的包含中文字体和完整texlive的镜像
FROM wrm244/sharelatex:with-texlive-full
# 设置环境变量
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 安装必要的系统依赖
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
python3 \
python3-pip \
nodejs \
npm \
nginx \
supervisor \
&& rm -rf /var/lib/apt/lists/*
# 创建必要的目录
RUN mkdir -p /var/lib/sharelatex \
&& mkdir -p /var/log/supervisor \
&& mkdir -p /app
# 设置工作目录
WORKDIR /app
# 复制应用文件(如果有的话)
# COPY . /app
# 安装Python依赖(如果需要的话)
# COPY requirements.txt .
# RUN pip3 install -r requirements.txt
# 创建supervisor配置文件
RUN cat > /etc/supervisor/conf.d/supervisord.conf << 'EOF'
[unix_http_server]
file=/var/run/supervisor.sock
chmod=0700
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
[program:sharelatex]
command=/sbin/my_init -- /bin/bash -c "cd /overleaf/services/web && npm start"
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/sharelatex.err.log
stdout_logfile=/var/log/supervisor/sharelatex.out.log
user=root
environment=HOME="/root",USER="root"
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/nginx.err.log
stdout_logfile=/var/log/supervisor/nginx.out.log
EOF
# 创建nginx配置
RUN cat > /etc/nginx/sites-available/default << 'EOF'
server {
listen 7860;
server_name _;
location / {
proxy_pass http://localhost:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
}
EOF
# 设置环境变
ENV SHARELATEX_MONGO_URL=mongodb://127.0.0.1/sharelatex
ENV SHARELATEX_REDIS_HOST=127.0.0.1
ENV REDIS_HOST=127.0.0.1
ENV SHARELATEX_APP_NAME="Taka Overleaf"
ENV SHARELATEX_LISTEN_IP=0.0.0.0
ENV SHARELATEX_PORT=80
# 为Hugging Face Spaces设置特定环境变量
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV GRADIO_SERVER_PORT=7860
# 暴露端口(Hugging Face Spaces默认使用7860端口)
EXPOSE 7860
# 创建启动脚本
RUN cat > /start.sh << 'EOF'
#!/bin/bash
# 启动MongoDB
mongod --fork --logpath /var/log/mongodb.log --dbpath /var/lib/mongodb
# 启动Redis
redis-server --daemonize yes
# 等待数据库服务启动
sleep 5
# 启动supervisor管理的服务
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
EOF
RUN chmod +x /start.sh
# 创建默认的数据目录
RUN mkdir -p /var/lib/mongodb \
&& chown -R mongodb:mongodb /var/lib/mongodb
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# 启动命令
CMD ["/start.sh"] |