Spaces:
Sleeping
Sleeping
| # ============================================================================= | |
| # Sub2API - 自部署 PostgreSQL + Redis 一体化镜像 | |
| # ============================================================================= | |
| FROM ghcr.io/wei-shaw/sub2api:latest | |
| # 安装所有必要工具(修正包名:postgresql-server → postgresql) | |
| RUN apk add --no-cache \ | |
| python3 \ | |
| py3-bcrypt \ | |
| redis \ | |
| postgresql-client \ | |
| postgresql \ | |
| postgresql-contrib \ | |
| openssl \ | |
| tzdata \ | |
| su-exec \ | |
| wget # 用于健康检查,若基础镜像已有可删除 | |
| # 创建软链接,让脚本中的 /app/hub-gateway 指向实际的 /app/sub2api | |
| RUN ln -s /app/sub2api /app/hub-gateway | |
| # 复制自定义启动脚本(覆盖官方默认脚本) | |
| COPY start-space.sh /app/start-space.sh | |
| RUN chmod +x /app/start-space.sh | |
| # 环境变量默认值 | |
| ENV SERVER_PORT=7860 \ | |
| TZ=Asia/Shanghai \ | |
| PGDATA=/var/lib/postgresql/data \ | |
| POSTGRES_USER=sub2api \ | |
| POSTGRES_DB=sub2api \ | |
| POSTGRES_PASSWORD=changeme | |
| # 健康检查(依赖 wget,现已安装) | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=5 \ | |
| CMD wget -q -T 5 -O /dev/null http://localhost:${SERVER_PORT:-7860}/health || exit 1 | |
| EXPOSE 7860 | |
| ENTRYPOINT ["/app/start-space.sh"] |