宋国顺 commited on
Commit
14e1745
·
1 Parent(s): 451ced1

Deploy to HF

Browse files
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方 Synapse 镜像
2
+ FROM matrixdotorg/synapse:latest
3
+
4
+ # 切换到 root 用户
5
+ USER root
6
+
7
+ # 1. 安装编译依赖 + gettext (用于替换环境变量)
8
+ RUN apt-get update && apt-get install -y \
9
+ git \
10
+ gcc \
11
+ python3-dev \
12
+ libffi-dev \
13
+ libxml2-dev \
14
+ libxslt-dev \
15
+ libjpeg-dev \
16
+ zlib1g-dev \
17
+ libpq-dev \
18
+ gettext-base \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # 2. 升级 pip
22
+ RUN pip install --upgrade pip setuptools wheel
23
+
24
+ # 3. 安装 S3 插件
25
+ RUN pip install https://github.com/matrix-org/synapse-s3-storage-provider/archive/refs/heads/main.zip
26
+
27
+ # 4. 设置端口
28
+ ENV SYNAPSE_HTTP_PORT=7860
29
+
30
+ # 5. 复制配置文件 (作为模板)
31
+ COPY homeserver.yaml /data/homeserver.yaml.template
32
+
33
+ # 6. 修正权限
34
+ RUN chown -R 991:991 /data && chmod -R 755 /data
35
+
36
+ # 切换回 Synapse 用户
37
+ USER 991
38
+
39
+ # 7. 【核心修复】使用 ENTRYPOINT 覆盖默认启动脚本
40
+ # 这样 Docker 就不会去调原来的 /start.py,而是直接运行我们的 shell 命令
41
+ # 命令逻辑:先替换变量生成 yaml,然后手动调用 /start.py 启动服务
42
+ ENTRYPOINT ["/bin/sh", "-c", "envsubst < /data/homeserver.yaml.template > /data/homeserver.yaml && /start.py run"]
README.md CHANGED
@@ -1 +1,13 @@
1
- # chat
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Matrix Chat Server
3
+ emoji: 💬
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ app_port: 7860
10
+ ---
11
+
12
+ # My Matrix Chat Server
13
+ 基于 Synapse 的加密聊天服务器。
guoshun2003-chatserver.hf.space.log.config ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 1
2
+
3
+ formatters:
4
+ precise:
5
+
6
+ format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
7
+
8
+
9
+ handlers:
10
+
11
+
12
+ console:
13
+ class: logging.StreamHandler
14
+ formatter: precise
15
+
16
+ loggers:
17
+ # This is just here so we can leave `loggers` in the config regardless of whether
18
+ # we configure other loggers below (avoid empty yaml dict error).
19
+ _placeholder:
20
+ level: "INFO"
21
+
22
+
23
+
24
+ synapse.storage.SQL:
25
+ # beware: increasing this to DEBUG will make synapse log sensitive
26
+ # information such as access tokens.
27
+ level: INFO
28
+
29
+
30
+
31
+
32
+ root:
33
+ level: INFO
34
+
35
+
36
+ handlers: [console]
37
+
38
+
39
+ disable_existing_loggers: false
guoshun2003-chatserver.hf.space.signing.key ADDED
@@ -0,0 +1 @@
 
 
1
+ ed25519 a_gexg 3WESxjrkSfaAP2GBpBLhX573nLwnoALOvlP6yhnzzuM
homeserver.yaml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration file for Synapse.
2
+ #
3
+ # This is a YAML file: see [1] for a quick introduction. Note in particular
4
+ # that *indentation is important*: all the elements of a list or dictionary
5
+ # should have the same indentation.
6
+ #
7
+ # [1] https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
8
+ #
9
+ # For more information on how to configure Synapse, including a complete accounting of
10
+ # each option, go to docs/usage/configuration/config_documentation.md or
11
+ # https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html
12
+ server_name: "guoshun2003-chatserver.hf.space"
13
+
14
+ # 允许 Synapse Admin 等外部网页工具连接
15
+ enable_cors: true
16
+
17
+ # 开启注册,家人注册完后建议改为 false
18
+ enable_registration: true
19
+
20
+ # 【关键】添加这一行:允许无验证(无邮箱/手机号)直接注册
21
+ enable_registration_without_verification: true
22
+
23
+ # 【可选】顺手把日志里的另一个警告也消掉
24
+ suppress_key_server_warning: true
25
+
26
+ pid_file: /data/homeserver.pid
27
+ listeners:
28
+ - port: 7860 # 必须是 7860
29
+ tls: false
30
+ type: http
31
+ x_forwarded: true # 必须开启
32
+ bind_addresses: ['0.0.0.0']
33
+ resources:
34
+ - names: [client, federation]
35
+ compress: false
36
+ database:
37
+ name: psycopg2
38
+ allow_unsafe_locale: true
39
+ args:
40
+ user: "${NEON_USER}" # 变成了变量
41
+ password: "${NEON_PASSWORD}" # 变成了变量
42
+ database: "neondb"
43
+ host: "${NEON_HOST}" # 变成了变量
44
+ port: 5432
45
+ cp_min: 5
46
+ cp_max: 10
47
+ # log_config: "/data/guoshun2003-chatserver.hf.space.log.config"
48
+ media_store_path: /data/media_store
49
+ media_storage_providers:
50
+ - module: s3_storage_provider.S3StorageProviderBackend
51
+ store_local: True
52
+ store_remote: True
53
+ store_synchronous: True
54
+ config:
55
+ bucket: "${S3_BUCKET}" # 变成了变量
56
+ region_name: "us-east-1"
57
+ endpoint_url: "https://s3.filebase.com"
58
+ access_key: "${AWS_ACCESS_KEY_ID}" # 变成了变量
59
+ secret_key: "${AWS_SECRET_ACCESS_KEY}" # 变成了变量
60
+ registration_shared_secret: "QzIvPq1Ra8Of~X.eS8H&KYdEXtXbsC0kob,Dr3^R#NcRq06Dok"
61
+ report_stats: false
62
+ macaroon_secret_key: "fIR@lA;C@.;D=gDis1*6LtrfSk69CL8ZG3#w0bDu1-4Xht9BgA"
63
+ form_secret: ":Fz4eLsjFF;ADydptUu.p:3l3L:3P:#u8lR2M5LKgBBN=D~OhH"
64
+ signing_key_path: "/data/guoshun2003-chatserver.hf.space.signing.key"
65
+ trusted_key_servers:
66
+ - server_name: "matrix.org"
67
+
68
+
69
+ # vim:ft=yaml