File size: 1,104 Bytes
9ab2520
 
190e8d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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"]