6 步搭建一个飞机大战游戏

DevOps 实践
DevOps 实践是一种开发、测试运维一体化的模式,其实践的外在表现一般包括了如代码仓库、构建、测试、发布、配置、监控等工具形成的一个完整的工具链或者说开发平台,以华为云软件开发平台 DevCloud 为例,展示飞机大战游戏开发的 DevOps 实践流程。

实验介绍
项目名称:飞机大战游戏
项目简介:一个用 Cocos Creator 开发的 Web 游戏,可以进行飞机大战。
开发语言:JavaScript(49.3%)、CSS(36.6%)、Html(14%)
部署环境:CentOS 7.6 64bit for Kai1s +jdk1.8
涉及云服务:华为云 DevCloud、华为云弹性云服务器 ECS
操作流程

操作步骤
创建私有云
步骤 1:在华为云服务列表找到“服务列表”,进入华为云“虚拟私有云 VPC”,创建虚拟私有云,配置虚拟私有云名称和子网名称,其他默认配置,点击立即创建;




步骤 2:创建安全组并添加规则
创建安全组
名称:sg-plane
企业:default
模板:通用 Web 服务器
描述:无
添加规则:添加入向规则
优先级:1 协议端口:TCP 输入:8080




创建项目
在华为云官网产品列表中,前往“软件开发平台 DevCloud”的管理控制台,新建项目;
项目流程:看板
项目名称:自定义



创建代码仓库
进入代码->代码托管,导入外部仓库:
源仓库地址:https://codehub.devcloud.cn-north4.huaweicloud.com/yxdmmsymbgl00001/planeGame.git
源仓库访问权限:不需要用户名/密码
勾选“我已阅读并同意 《隐私政策声明》 和 《软件开发服务使用声明》”
点击“下一步”按钮
自定义代码仓库名称
其他默认值,最后确认





新建编译构建任务
在“构建 &制品”中选择“编译构建”后,新建任务:
步骤 1:选择 Shell 模板,在命令行中输入 zip -qr WebGames.zip ./
步骤 2:在 Shell 下方增加“上传软件包到软件发布库”
构建包路径:WebGames.zip 发布版本号:1.0.0 包名:WebGames
步骤 3:新建并执行






新建部署任务
步骤 1:进入“控制台”选择“服务列表”购买弹性云服务器 ECS,并进行配置;
计费模式:按需收费
区域:华北-北京四
可用区:随机分配
CPU 架构:鲲鹏计算
规格:kai1s.xlarge.1(4 核 4G)
镜像:CentOS 7.6 64bit for Kai1s(40GB)
网络:选择本实验创建的虚拟私有云
安全组:选择本实验创建的安全组
云服务器名称:自定义(如:ecs-plane-kunpeng)
密码:自定义









步骤 2:进入华为云 DevCloud 控制台,选择“部署”->“主机管理”;
添加主机组,输入主机名,选择 linux 操作系统,点击保存;
添加主机;
输入自定义主机名称,如 planewar
IP(云服务弹性公网 IP)
认证方式:密码
用户名:root
密码:自己云服务器 ECS 的密码
ssh 端口:22
勾选我已阅读…,点击添加
添加成功后,显示验证成功。



步骤 3:重新进入部署服务,新建任务,选择 Tomcat 应用部署模板
点击“选择部署来源”下方的加号,添加“解压文件”,配置:
压缩文件路径:${download_path}/WebGames.zip,解压目录:${download_path}/WebGames;
“参数设置”页中,将以下参数进行修改,其余参数保持默认不变
${host_group}:ecs_group_planewar(即本实验中创建的主机组)
${package_url}:/WebGames/1.0.0/WebGames.zip
Service_port:8080


步骤 4:访问应用


释放云资源
本实验需要释放的资源有:弹性云服务器 ECS、虚拟私有云和安全组。
步骤 1:前往“弹性云服务器 ECS”管理控制台,释放资源;


步骤 2:前往“虚拟私有云 VPC”管理控制台,先删除所有子网,再删除虚拟私有云;






步骤 3:进入“访问控制”中的安全组,删除需要删除的安全组。


版权声明: 本文为 InfoQ 作者【华为云开发者联盟】的原创文章。
原文链接:【http://xie.infoq.cn/article/1d98ee7647f103c428808dc2b】。文章转载请联系作者。
评论