Spaces:
Paused
Paused
| FROM weishaw/sub2api:0.1.81 | |
| USER root | |
| # 安装 PostgreSQL + supervisor | |
| RUN apt-get update && \ | |
| apt-get install -y postgresql postgresql-contrib supervisor && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 创建 PostgreSQL 数据目录 | |
| RUN mkdir -p /var/lib/postgresql/data && \ | |
| chown -R postgres:postgres /var/lib/postgresql | |
| # 初始化数据库 | |
| USER postgres | |
| RUN /usr/lib/postgresql/*/bin/initdb -D /var/lib/postgresql/data | |
| # 配置允许本地连接 | |
| RUN echo "listen_addresses='localhost'" >> /var/lib/postgresql/data/postgresql.conf && \ | |
| echo "host all all 127.0.0.1/32 trust" >> /var/lib/postgresql/data/pg_hba.conf | |
| # 创建数据库和用户 | |
| RUN /usr/lib/postgresql/*/bin/pg_ctl -D /var/lib/postgresql/data -o "-c listen_addresses='localhost'" -w start && \ | |
| psql --username=postgres -c "CREATE DATABASE sub2api;" && \ | |
| pg_ctl -D /var/lib/postgresql/data -m fast -w stop | |
| USER root | |
| # Supervisor 配置 | |
| RUN mkdir -p /etc/supervisor/conf.d | |
| COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
| # 暴露 sub2api 端口(假设 8000) | |
| EXPOSE 8000 | |
| CMD ["/usr/bin/supervisord"] | |