cacode commited on
Commit
190e8d8
·
verified ·
1 Parent(s): 1855bab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -0
Dockerfile CHANGED
@@ -1,2 +1,36 @@
1
  FROM weishaw/sub2api:0.1.81
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM weishaw/sub2api:0.1.81
2
 
3
+ USER root
4
+
5
+ # 安装 PostgreSQL + supervisor
6
+ RUN apt-get update && \
7
+ apt-get install -y postgresql postgresql-contrib supervisor && \
8
+ rm -rf /var/lib/apt/lists/*
9
+
10
+ # 创建 PostgreSQL 数据目录
11
+ RUN mkdir -p /var/lib/postgresql/data && \
12
+ chown -R postgres:postgres /var/lib/postgresql
13
+
14
+ # 初始化数据库
15
+ USER postgres
16
+ RUN /usr/lib/postgresql/*/bin/initdb -D /var/lib/postgresql/data
17
+
18
+ # 配置允许本地连接
19
+ RUN echo "listen_addresses='localhost'" >> /var/lib/postgresql/data/postgresql.conf && \
20
+ echo "host all all 127.0.0.1/32 trust" >> /var/lib/postgresql/data/pg_hba.conf
21
+
22
+ # 创建数据库和用户
23
+ RUN /usr/lib/postgresql/*/bin/pg_ctl -D /var/lib/postgresql/data -o "-c listen_addresses='localhost'" -w start && \
24
+ psql --username=postgres -c "CREATE DATABASE sub2api;" && \
25
+ pg_ctl -D /var/lib/postgresql/data -m fast -w stop
26
+
27
+ USER root
28
+
29
+ # Supervisor 配置
30
+ RUN mkdir -p /etc/supervisor/conf.d
31
+ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
32
+
33
+ # 暴露 sub2api 端口(假设 8000)
34
+ EXPOSE 8000
35
+
36
+ CMD ["/usr/bin/supervisord"]