简体   繁体   English

如何使用 Azure DevOps 将 docker 实例部署和管理到 Azure 中?

[英]How to deploy and manage docker instances into Azure using Azure DevOps?

Our project requires two docker instances:我们的项目需要两个 docker 实例:

  • a custom image built on top of an official PHP image via a Dockerfile通过 Dockerfile 在官方 PHP 镜像之上构建的自定义镜像
    • needs access to the PHP scripts (currently in the same git repository as the Dockerfile)需要访问 PHP 脚本(当前与 Dockerfile 位于同一 git 存储库中)
    • needs access to the MySQL server mentioned bellow需要访问下面提到的 MySQL 服务器
    • needs access to a persistent volume containing data files and log files需要访问包含数据文件和日志文件的持久卷
    • depends on environment values to get MySQL passwords and other secrets or configuration取决于环境值来获取 MySQL 密码和其他机密或配置
  • an official MySQL image一个官方的 MySQL 镜像
    • needs access to a persistent volume containing data files需要访问包含数据文件的持久卷

Public access to the MySQL should be forbidden.应禁止公开访问 MySQL。 However, there should be a way to connect to the MySQL server from specific computers / specific AAD users if needed to manually alter the database or get a dump of it.但是,如果需要手动更改数据库或获取数据库转储,应该有一种方法可以从特定计算机/特定 AAD 用户连接到 MySQL 服务器。

The PHP web should be available via HTTPS using a custom or Let's Encrypt certificate. PHP Web 应该可以使用自定义证书或 Let's Encrypt 证书通过 HTTPS 访问。 Not sure, whether it should be handled inside the PHP instance, via a proxy instance, via Azure API gateway or another way.不确定是否应该在 PHP 实例内部、通过代理实例、通过 Azure API 网关或其他方式处理。

After deploing a new PHP image, the CI should run a script inside the docker image which migrate the MySQL schema and data.在部署一个新的 PHP 镜像后,CI 应该在 docker 镜像中运行一个脚本来迁移 MySQL 架构和数据。 The script should get a MySQL "root"-like password so it has enough permissions to do its work.该脚本应该获得一个类似 MySQL 的“root”密码,以便它有足够的权限来完成它的工作。

We use Azure DevOps for git repositories and for CI.我们将 Azure DevOps 用于 git 存储库和 CI。

I was able to set up a Azure DevOps Pipeline YAML to build and publish the custom PHP image to an Azure Container Repository.我能够设置 Azure DevOps Pipeline YAML 来构建自定义 PHP 映像并将其发布到 Azure 容器存储库。 However, I found no suitable tasks to start/configure/deploy/stop a Container Instance from Azure DevOps Releases.但是,我发现没有合适的任务可以从 Azure DevOps Releases 启动/配置/部署/停止容器实例。 Neither I am sure what to use / how to add HTTPS support.我也不知道要使用什么/如何添加 HTTPS 支持。

It's my first docker deployment in production - up to now, I was only using docker for development.这是我在生产中的第一个 docker 部署 - 到目前为止,我只使用 docker 进行开发。 I've tried to study the docs, search net but still has no idea what the best practices are, how to build it together.我试图研究文档、搜索网络,但仍然不知道最佳实践是什么,如何一起构建它。 I would appreaciate any, even partial help and hints, how to correctly deploy the thing.我会感谢任何,甚至是部分帮助和提示,如何正确部署这个东西。 Thanks.谢谢。

I was able to set up a Azure DevOps Pipeline YAML to build and publish the custom PHP image to an Azure Container Repository. However, I found no suitable tasks to start/configure/deploy/stop a Container Instance from Azure DevOps Releases. Neither I am sure what to use / how to add HTTPS support.

Since you already succeed set CI to build the docker image and push it to Azure Container Registry (ACR).由于您已经成功设置 CI 来构建 docker 映像并将其推送到 Azure 容器注册表 (ACR)。

You could then use both Azure App Service deploy and Azure Web App for Containers task to handle the deploy.然后,您可以使用 Azure App Service 部署和 Azure Web App for Containers 任务来处理部署。

The Azure WebApp Container task similar to other built-in Azure tasks, requires an Azure service connection as an input. Azure WebApp 容器任务与其他内置 Azure 任务类似,需要Azure 服务连接作为输入。 The Azure service connection stores the credentials to connect from Azure Pipelines or Azure DevOps Server to Azure. Azure 服务连接存储用于从 Azure Pipelines 或 Azure DevOps 服务器连接到 Azure 的凭据。

Kindly take a look at below blogs show:how do people actually build their containers and then deploy them to each environment?:请看看下面的博客展示:人们如何实际构建他们的容器,然后将它们部署到每个环境中?:

Neither I am sure what to use / how to add HTTPS support.

For this part, according to my personal understanding, it should more related to Docker image side.对于这部分,根据我个人的理解,应该更多地与Docker镜像端相关。 This should not related to Azure DevOps pipeline side.这应该与 Azure DevOps 管道端无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure DevOps -- 使用Docker-Compose任务部署到Azure容器实例 - Azure DevOps -- using Docker-Compose task to deploy to Azure Container Instances 如何使用Azure DevOps在Nure应用服务上部署Nupkg文件 - How to deploy nupkg files on azure app service using azure devOps 使用 azure devops 管道部署 azure 订阅 - Deploy azure subscription using azure devops pipeline 如何使用 Rest API 管理 Azure DevOps 组权限 - How to manage Azure DevOps group permissions using Rest API 如何使用 azure devops 在多环境部署中管理密码和 ConnectionString? - How to manage passwords and ConnectionStrings in a multi environment deployment using azure devops? 在 azure devops 上创建管道以在 azure 应用服务上部署 docker 容器? - Create a pipeline on azure devops to deploy a docker container on azure app service? 如何使用 Azure DevOps 部署 create-react-app? - How to deploy a create-react-app using Azure DevOps? Azure DevOps部署概述 - Azure DevOps deploy overview 无法使用 azure devops CI 管道创建 azure 计算实例 - Could not create azure compute instances using azure devops CI pipeline 如何使用Azure DevOps部署多个应用程序? - How to deploy multiple apps with Azure DevOps?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM