使用 Github 和 Docker 的 Web 开发工作流
Web development workflow using Github and Docker
我学习了 github 和 docker 的基础知识,它们在我的环境中都运行良好。在我的服务器上,我有项目目录,每个目录都有一个 docker-compose.yml 到 运行 必要的容器。这些项目目录还包含特定应用程序的实际源文件,这些文件在启动时映射到容器内的虚拟位置。
我现在的问题是 - 如何创建一个专业的工作流程来封装所有这些?整个目录(包括 docker-compose 文件)是否应该存在于 github 上?因此,每次进行更改时,我都会将代码推送到我的远程服务器,通过 SSH 连接到服务器,提取最新文件并重建容器。这种重建当然意味着每次都从 dockerhub 中拉取所需的图像。
Should the whole directory (including the docker-compose files) live on github?
最好保留所有源代码,包括docker文件、配置...版本。因此,您应该将所有源代码、docker 文件和 dockercompose 放在一个 git 库中。这对于 github 上具有 docker 图片的项目来说非常常见。
Thus each time changes are made I push the code to my remote, SSH to the server, pull the latest files and rebuild the container
理想情况下,应使用 Jenkins 等工具将此过程封装在 CI 工作流程中。您基本上将代码推送到 git 存储库,
这会触发一个编译代码的 jenkins 作业,构建图像并将图像推送到 docker 注册表。
This rebuilding of course means pulling the required images from dockerhub each time.
Docker 足够聪明,可以缓存之前拉取的基础镜像。因此它只会在第一次构建时拉取一次基础镜像。
我学习了 github 和 docker 的基础知识,它们在我的环境中都运行良好。在我的服务器上,我有项目目录,每个目录都有一个 docker-compose.yml 到 运行 必要的容器。这些项目目录还包含特定应用程序的实际源文件,这些文件在启动时映射到容器内的虚拟位置。
我现在的问题是 - 如何创建一个专业的工作流程来封装所有这些?整个目录(包括 docker-compose 文件)是否应该存在于 github 上?因此,每次进行更改时,我都会将代码推送到我的远程服务器,通过 SSH 连接到服务器,提取最新文件并重建容器。这种重建当然意味着每次都从 dockerhub 中拉取所需的图像。
Should the whole directory (including the docker-compose files) live on github?
最好保留所有源代码,包括docker文件、配置...版本。因此,您应该将所有源代码、docker 文件和 dockercompose 放在一个 git 库中。这对于 github 上具有 docker 图片的项目来说非常常见。
Thus each time changes are made I push the code to my remote, SSH to the server, pull the latest files and rebuild the container
理想情况下,应使用 Jenkins 等工具将此过程封装在 CI 工作流程中。您基本上将代码推送到 git 存储库, 这会触发一个编译代码的 jenkins 作业,构建图像并将图像推送到 docker 注册表。
This rebuilding of course means pulling the required images from dockerhub each time.
Docker 足够聪明,可以缓存之前拉取的基础镜像。因此它只会在第一次构建时拉取一次基础镜像。