gsuid_core/Dockerfile
lilixxs 9c3b04b9b4
🚀 优化 docker 镜像构建相关代码 (#108)
* 修正 docker file 的问题

* 将国内和国外的 dockerfile 分开

* 改正 bug

* 改正挂载问题,延时挂载

* 改进,使用脚本做集中指令处理,方便后续扩展

* 在 Serverless 平台集成测试

* 更新workdir,使构建出的镜像路径与原文档一直

* 国内构建源也同步修改

* 完善版 docker 代码

* 完善文档和输出信息

* 🚨 `pre-commit-ci`修复格式错误

* 修正官方源

* 针对海外版镜像构建,删除 python 依赖的加速镜像

* 更正格式

* 测试替换功能

* 更正2

* 修正3

* 测试1

* 测试2

* 测试3

* 需要更新 lock 文件中的包地址

* lock 文件需要指定外网地址更新 lock 文件

* uv 包管理器的镜像设置也要修改
1. 删掉 uv.toml 的镜像源
2. 指定使用官方源更新 uv.lock 文件

* 针对海外构建 docker 文件的更新

* 更新海外 docker 构建文件,更新官方源

* 针对海外构建 docker 文件的更新,去掉官方镜像加速源,完善说明

* 🚨 `pre-commit-ci`修复格式错误

* 小问题😂

---------

Co-authored-by: lilixxs <lilixxs@email.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-02-23 03:41:08 +08:00

33 lines
1.8 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 基准镜像更新版本至官方文档推荐版本3.12 | Update base image to the version recommended by the official documentation: 3.12
FROM m.daocloud.io/docker.io/library/python:3.12-slim-bullseye
# 镜像工作路径保持与文档一致 | Keep the working directory consistent with the documentation
WORKDIR /gsuid_core
# 暴露 8765 端口 | Expose port 8765
EXPOSE 8765
ENV PATH="${PATH}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# 可选参数配置见 entrypoint 脚本 | Optional parameter configuration can be found in the entrypoint script
# 调整层顺序,这些安装是固定的,单独分层 | Adjust layer order, these installations are fixed, separate layer
RUN echo build start ---------------------------- \
&& apt-get update -y \
&& apt install curl git -y \
&& apt-get autoremove \
&& apt-get clean \
&& pip install --no-cache-dir --upgrade pip \
&& pip install uv
# 下面的内容与项目代码相关,有可能变换,单独分层 | The following content is related to project code and may change, separate layer
# 代码添加到根目录下,保证路径与文档一致 | Add code to the root directory to ensure the path is consistent with the documentation
ADD ./ /gsuid_core/
# 如果是海外用户,删除 uv.toml 中镜像加速相关设置,并更新 lock 文件中的包地址 | If you are an overseas user, delete the mirror acceleration settings in uv.toml and update the package addresses in the lock file
RUN uv sync --index "https://pypi.org/simple" && \
chmod +x /gsuid_core/docker-entrypoint.sh && \
echo build end ----------------------------
# 将需要初始化的一些代码放到 entrypoint 中 | Put some initialization code into the entrypoint
ENTRYPOINT [ "/gsuid_core/docker-entrypoint.sh" ]
# 最后启动服务 | Finally, start the service
CMD ["uv", "run", "core"]