Update Dockerfile
Browse files- Dockerfile +13 -13
Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# 使用作者预构建好的官方镜像
|
| 2 |
FROM ghcr.io/chenyme/grok2api:latest
|
| 3 |
|
| 4 |
# 切换到 root 用户以便安装工具和修改文件
|
|
@@ -7,32 +7,32 @@ USER root
|
|
| 7 |
# 安装必要的工具:git (用于克隆获取配置文件), openssl, sed
|
| 8 |
RUN apk add --no-cache git openssl sed
|
| 9 |
|
| 10 |
-
# 克隆项目源码到临时目录
|
| 11 |
WORKDIR /tmp/repo
|
| 12 |
RUN git clone https://github.com/chenyme/grok2api.git .
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
RUN cp /tmp/repo/config.example.yaml /
|
| 19 |
|
| 20 |
-
# 自动生成密钥并写入 config.yaml
|
| 21 |
# 注意:请把下面 admin123456 修改为你想要的强密码
|
| 22 |
RUN JWT_SECRET=$(openssl rand -hex 32) && \
|
| 23 |
ENC_KEY=$(openssl rand -base64 32) && \
|
| 24 |
-
sed -i "s|jwtSecret:.*|jwtSecret: \"$JWT_SECRET\"|g" /
|
| 25 |
-
sed -i "s|credentialEncryptionKey:.*|credentialEncryptionKey: \"$ENC_KEY\"|g" /
|
| 26 |
-
sed -i 's|password:.*|password: "admin123456"|g' /
|
| 27 |
|
| 28 |
# 清理临时克隆的文件,减小镜像体积
|
| 29 |
RUN rm -rf /tmp/repo
|
| 30 |
|
| 31 |
# 赋予配置文件可读权限
|
| 32 |
-
RUN chmod 644 /
|
| 33 |
|
| 34 |
# 暴露 Hugging Face 需要的端口
|
| 35 |
EXPOSE 8000
|
| 36 |
|
| 37 |
-
# 启动容器
|
| 38 |
-
CMD ["/app/grok2api", "--config", "/
|
|
|
|
| 1 |
+
# 使用作者预构建好的官方镜像
|
| 2 |
FROM ghcr.io/chenyme/grok2api:latest
|
| 3 |
|
| 4 |
# 切换到 root 用户以便安装工具和修改文件
|
|
|
|
| 7 |
# 安装必要的工具:git (用于克隆获取配置文件), openssl, sed
|
| 8 |
RUN apk add --no-cache git openssl sed
|
| 9 |
|
| 10 |
+
# 克隆项目源码到临时目录
|
| 11 |
WORKDIR /tmp/repo
|
| 12 |
RUN git clone https://github.com/chenyme/grok2api.git .
|
| 13 |
|
| 14 |
+
# 确保原镜像设定的配置目录存在并赋予相关权限
|
| 15 |
+
RUN mkdir -p /run/grok2api && chown -R grok2api:grok2api /run/grok2api
|
| 16 |
|
| 17 |
+
# 将配置文件复制到原镜像要求读取的路径
|
| 18 |
+
RUN cp /tmp/repo/config.example.yaml /run/grok2api/config.yaml
|
| 19 |
|
| 20 |
+
# 自动生成密钥并写入 /run/grok2api/config.yaml
|
| 21 |
# 注意:请把下面 admin123456 修改为你想要的强密码
|
| 22 |
RUN JWT_SECRET=$(openssl rand -hex 32) && \
|
| 23 |
ENC_KEY=$(openssl rand -base64 32) && \
|
| 24 |
+
sed -i "s|jwtSecret:.*|jwtSecret: \"$JWT_SECRET\"|g" /run/grok2api/config.yaml && \
|
| 25 |
+
sed -i "s|credentialEncryptionKey:.*|credentialEncryptionKey: \"$ENC_KEY\"|g" /run/grok2api/config.yaml && \
|
| 26 |
+
sed -i 's|password:.*|password: "admin123456"|g' /run/grok2api/config.yaml
|
| 27 |
|
| 28 |
# 清理临时克隆的文件,减小镜像体积
|
| 29 |
RUN rm -rf /tmp/repo
|
| 30 |
|
| 31 |
# 赋予配置文件可读权限
|
| 32 |
+
RUN chmod 644 /run/grok2api/config.yaml
|
| 33 |
|
| 34 |
# 暴露 Hugging Face 需要的端口
|
| 35 |
EXPOSE 8000
|
| 36 |
|
| 37 |
+
# 启动容器 (原镜像自带 entrypoint.sh,直接使用默认启动命令即可,它会自动读取上面路径的配置)
|
| 38 |
+
CMD ["/app/grok2api", "--config", "/run/grok2api/config.yaml", "--listen", "0.0.0.0:8000"]
|