Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Provide a Docker container image for the project. #47

Open
ozline opened this issue Dec 13, 2023 · 0 comments
Open

Proposal: Provide a Docker container image for the project. #47

ozline opened this issue Dec 13, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ozline
Copy link
Collaborator

ozline commented Dec 13, 2023

Refer to DeepMD-kit

I believe this project can provide Docker images to simplify usage, while also offering more comprehensive introductory documentation.

At the same time, we can use mirrors to build Docker container instances and configure the corresponding Python settings inside the containers (as we all know, Python configuration on a physical machine is complex).
After mapping is done, we can develop within the containers without affecting the host machine's Python.

If possible, I will try to submit a pull request in the next few days to implement this feature.

But first, I need to know if this proposal is feasible.


事实上,我们可以使用 Docker 来规避复杂的环境配置。目前的 Docker 方案侧重于 dev,生产部署的方案待前者合入后再做考虑

为开发者提供的容器

  1. 将整个项目源代码打包进一个 Docker 镜像中,并推送至云服务商的容器镜像服务中(或 docker hub)。在镜像中我们配置好了这个项目所需的一切环境,除了诸如 redis、etcd 等中间件
  2. 在独立物理机上,我们将镜像拉下来,并做 volume 映射,将源代码的目录映射到容器外部
  3. 我们在这个映射目录中对项目做修改
  4. 修改后我们在容器内重新运行makefile 的编译指令,在容器内启动。

这样做我们可能需要做这些更改:

  1. 修改 Makefile,后续的 Makefile 中部分方法(如 make xxx)限定为在容器内工作。我们可以通过设置一个特殊的环境变量来做到这个效果
  2. 编写 Dockerfile,这个 Dockerfile 会很简单,只包含了COPY/ADD

需要注意的是,这个项目使用了 docker-compose 来提供中间件的快速启动,我们需要在外部环境中运行这个 compose 而不是在容器内

也就是说,这个容器只提供了编译部署所需要的环境,其余的我们均需要在外部做。此时这个容器的作用更类似于一个虚拟机环境。

这样做的好处除了简化 dev 难度,同时我们规避了在 Windows 下兼容性的问题(例如 Windows 下需要做一些特殊调整才可以运行 shell)

为部署提供的容器

我们可以通过一个新的 Dockerfile,这个 Dockerfile 负责实现常用的编译二进制文件的命令,对项目进行封装,将所有编译好的binary 和 python 文件放进同一个镜像中

我们编写一个 start-container.sh 脚本,这个 shell 脚本内明确声明用户不可调用

在利用这个镜像启动容器时,我们通过指定参数,callback 给这个 start-container.sh 脚本,以便让脚本知道应该运行哪个服务。

@CocaineCong CocaineCong assigned CocaineCong and ozline and unassigned CocaineCong Dec 14, 2023
@CocaineCong CocaineCong added the enhancement New feature or request label Dec 14, 2023
@CocaineCong CocaineCong added this to the v0.1.3 milestone Dec 14, 2023
@ozline ozline changed the title Suggestion: Provide a Docker container image for the project. Proposal: Provide a Docker container image for the project. Dec 14, 2023
@CocaineCong CocaineCong modified the milestones: v0.1.3, v0.1.4 Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants