Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +12 -16
Dockerfile
CHANGED
|
@@ -1,23 +1,17 @@
|
|
| 1 |
# =============================================================================
|
| 2 |
-
# Sub2API Hugging Face Space Dockerfile
|
| 3 |
# =============================================================================
|
| 4 |
-
# This Space deploys from the exported root filesystem tar generated by the
|
| 5 |
-
# EvfWorkSpace/sub2api project, then layers the Space-specific startup wrapper
|
| 6 |
-
# on top. Keep sub2api-hf-rootfs.tar in this repository root.
|
| 7 |
-
# =============================================================================
|
| 8 |
-
|
| 9 |
FROM scratch
|
| 10 |
-
|
| 11 |
ADD sub2api-hf-rootfs.tar /
|
| 12 |
|
| 13 |
USER root
|
| 14 |
-
|
| 15 |
-
RUN apk add --no-cache redis
|
| 16 |
&& mv /app/sub2api /app/hub-gateway \
|
| 17 |
&& chmod +x /app/hub-gateway \
|
| 18 |
-
&& mkdir -p /tmp/gateway-data /tmp/gateway-redis
|
| 19 |
-
|
| 20 |
-
&& chown -R
|
| 21 |
|
| 22 |
ENV DATA_DIR=/tmp/gateway-data \
|
| 23 |
SERVER_HOST=0.0.0.0 \
|
|
@@ -26,17 +20,19 @@ ENV DATA_DIR=/tmp/gateway-data \
|
|
| 26 |
SERVER_MODE=release \
|
| 27 |
GIN_MODE=release \
|
| 28 |
AUTO_SETUP=true \
|
|
|
|
|
|
|
|
|
|
| 29 |
DATABASE_SSLMODE=require \
|
| 30 |
-
|
| 31 |
-
|
| 32 |
TZ=Asia/Shanghai
|
| 33 |
|
| 34 |
COPY start-space.sh /app/start-space.sh
|
| 35 |
RUN chmod +x /app/start-space.sh
|
| 36 |
|
| 37 |
EXPOSE 7860
|
| 38 |
-
|
| 39 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=5 \
|
| 40 |
CMD wget -q -T 5 -O /dev/null http://localhost:${SERVER_PORT:-7860}/health || exit 1
|
| 41 |
|
| 42 |
-
ENTRYPOINT ["/app/start-space.sh"]
|
|
|
|
| 1 |
# =============================================================================
|
| 2 |
+
# Sub2API Hugging Face Space Dockerfile (外部 PostgreSQL + 内置 Redis)
|
| 3 |
# =============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
FROM scratch
|
|
|
|
| 5 |
ADD sub2api-hf-rootfs.tar /
|
| 6 |
|
| 7 |
USER root
|
| 8 |
+
# 只安装 Redis 和必需工具,移除 postgresql 及 postgresql-client
|
| 9 |
+
RUN apk add --no-cache redis openssl tzdata su-exec python3 py3-bcrypt \
|
| 10 |
&& mv /app/sub2api /app/hub-gateway \
|
| 11 |
&& chmod +x /app/hub-gateway \
|
| 12 |
+
&& mkdir -p /tmp/gateway-data /tmp/gateway-redis \
|
| 13 |
+
# 不再创建 postgres 用户和 /tmp/gateway-postgres 目录
|
| 14 |
+
&& chown -R sub2api:sub2api /tmp/gateway-data /tmp/gateway-redis
|
| 15 |
|
| 16 |
ENV DATA_DIR=/tmp/gateway-data \
|
| 17 |
SERVER_HOST=0.0.0.0 \
|
|
|
|
| 20 |
SERVER_MODE=release \
|
| 21 |
GIN_MODE=release \
|
| 22 |
AUTO_SETUP=true \
|
| 23 |
+
# 数据库连接串由外部环境变量提供(您需要在运行时传入 Xata 的连接串)
|
| 24 |
+
# 这里不写默认值,强制外部注入
|
| 25 |
+
DATABASE_URL="" \
|
| 26 |
DATABASE_SSLMODE=require \
|
| 27 |
+
# Redis 将使用内置服务,默认连接 localhost:6379
|
| 28 |
+
REDIS_ADDR=localhost:6379 \
|
| 29 |
TZ=Asia/Shanghai
|
| 30 |
|
| 31 |
COPY start-space.sh /app/start-space.sh
|
| 32 |
RUN chmod +x /app/start-space.sh
|
| 33 |
|
| 34 |
EXPOSE 7860
|
|
|
|
| 35 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=5 \
|
| 36 |
CMD wget -q -T 5 -O /dev/null http://localhost:${SERVER_PORT:-7860}/health || exit 1
|
| 37 |
|
| 38 |
+
ENTRYPOINT ["/app/start-space.sh"]
|