File size: 2,315 Bytes
ddf1b87
 
 
 
 
 
44b72cc
ddf1b87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816d6fd
 
 
 
 
 
 
 
 
 
ddf1b87
 
dbb6591
ddf1b87
 
 
42508ee
ddf1b87
f2df1cf
 
 
 
 
 
 
 
 
 
 
ddf1b87
 
 
 
 
 
 
dbb6591
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 使用 PostgreSQL 作为基础镜像
FROM nikolaik/python-nodejs:python3.12-nodejs20

# 添加维护者信息
LABEL maintainer="ai来事 <交流群:https://qr61.cn/oohivs/qRp62U6>"

ARG CACHEBUST=1

# 设置构建参数,提供默认值
ARG WEBHOOK_URL=https://你的hf账户名-空间名.hf.space/


# 设置基本环境变量
ENV WEBHOOK_URL=${WEBHOOK_URL}

# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    unzip \
    gnupg \
    build-essential \
    sudo \
    vim \
    git \
    procps \
    lsof \
    net-tools \
    ca-certificates \
    openssl \
    tzdata \
    htop \
    jq \
    netcat-openbsd \
    redis-server \
    && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && dpkg-reconfigure --frontend noninteractive tzdata \
    # 清理
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# # 创建环境变量文件
# RUN --mount=type=secret,id=POSTGRES_USER,mode=0444,required=true \
#     --mount=type=secret,id=POSTGRES_PASSWORD,mode=0444,required=true \
#     --mount=type=secret,id=POSTGRES_DB,mode=0444,required=true \
#     --mount=type=secret,id=POSTGRESDB_HOST,mode=0444,required=true \
#     echo "export DB_POSTGRESDB_HOST=$(cat /run/secrets/POSTGRESDB_HOST)" >> /home/pn/.env && \
#     echo "export DB_POSTGRESDB_USER=$(cat /run/secrets/POSTGRES_USER)" >> /home/pn/.env && \
#     echo "export DB_POSTGRESDB_PASSWORD=$(cat /run/secrets/POSTGRES_PASSWORD)" >> /home/pn/.env && \
#     echo "export DB_POSTGRESDB_DATABASE=$(cat /run/secrets/POSTGRES_DB)" >> /home/pn/.env && \
#     chown pn:pn /home/pn/.env

# 创建工作目录
WORKDIR /home/pn/deepseek-free-api

# 复制启动脚本并创建数据目录
RUN cd /home/pn && git clone https://github.com/aigem/deepseek-free-api.git \
    && cd deepseek-free-api && npm i && npm run build && chown -R pn:pn /home/pn/deepseek-free-api

# 复制run.sh脚本到容器中
COPY run.sh /home/pn/deepseek-free-api/

# 复制ksa配置文件和可执行文件
COPY ksa.conf /home/pn/deepseek-free-api/
COPY ksa_x64 /home/pn/deepseek-free-api/

# 添加执行权限
RUN chmod +x /home/pn/deepseek-free-api/run.sh \
    && chmod +x /home/pn/deepseek-free-api/ksa_x64

# 暴露端口
EXPOSE 8000

# 切换到非 root 用户
USER pn

# 启动命令
CMD ["./run.sh"]