django - 自动将 gitlab 管道与 azure Web 服务连接
问题描述
我在 GitLab 上有我的 webapp 代码。我想使用 Azure Web 服务部署它。但我希望它这样,当我将代码推送到分支时,它将首先被推送到 GitLab,然后自动推送到 azure Web 服务上。有没有办法做到这一点?我在互联网上搜索了解决方案,但没有找到最新的解决方案。
解决方案
在 Azure 上设置 Gitlab Continuous (CI/CD)
使用 Docker 引擎部署 Ubuntu VM
- 转到https://gitlab.com/daveRendon/ubuntu-vm-with-docker-engine/blob/master/README.md并部署到 Azure
- 提供虚拟机参数,点击购买
- 配置 VM 后,转到 VM 配置并将 IP 地址更改为静态
- 使用 SSH 连接到虚拟机
设置 Gitlab
通过 SSH 连接到 Ubuntu 虚拟机
安装和配置必要的依赖项
sudo apt-get 更新
sudo apt-get install -y curl openssh-server ca-certificates
安装后缀
sudo apt-get install -y 后缀
在 Postfix 安装期间,可能会出现一个配置屏幕。选择“Internet 站点”并按 Enter。使用您服务器的外部 DNS 作为“邮件名称”,然后按 Enter。如果出现其他屏幕,请继续按 Enter 以接受默认值
添加 GitLab 包存储库
卷曲https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | 须藤重击
安装 GitLab 包。将https://gitlab.example.com更改为您要访问 GitLab 实例的 URL。
sudo EXTERNAL_URL=" https://gitlab.example.com " apt-get install gitlab-ee
浏览到主机名并使用默认帐户的用户名 root 登录
在 azure 上部署 webapp
使用 Azure 门户部署 ARM 模板:
在 Azure 上创建 Gitlab 项目
访问 Azure 上的 Gitlab
创建新项目
生成您的 SSH 密钥
https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair
在 Azure 上设置 Gitlab Continuous (CI/CD)
- 转到 Azure Web 应用
- 选择部署中心
- 选择源代码控制“外部”,然后单击继续
- 现在在 Build Provider 中选择“App Service Build Service”
- 添加 Gitlab URL 和 master 分支
- 在选择 Private Repository “YES” 并提供凭据,在这种情况下,用户 root 和先前创建的密码
- 测试在 Azure 上运行的 Gitlab 项目的更改,检查此处gitlab Continuous ci/cd with an azure web app
参考这里
推荐阅读
- java - 当我调用 Thread.start() 时如何调用 run() 方法?
- generics - 包中通用列表的最大数量?
- swift - xcode和模拟器之间的不同结果
- python-3.x - 删除字符串列表中的子字符串,维护顺序 - Python
- microsoft-graph-api - 如何在 Microsoft Graph API 中筛选 appRoleAssignments
- jpa - 如何解决 Java EE EJB Glassfish 错误 javax.naming.NamingException: Invocation exception: Got null ComponentInvocation?
- mysql - 休眠无法读取另一台服务器保存的条目
- html - 创建自适应背景图像
- java - 无法从 SQL Sever 2008 在 jLabel 上显示图像
- ruby-on-rails - 在 Ruby on Rails 5 中禁用 ActiveRecord