Logo Vincent
返回文章列表

AWS-CodeBuild

工具
AWS-CodeBuild

【前言】

aws code build用来构建代码

【创建项目】

地址

https://us-west-2.console.aws.amazon.com/codesuite/codebuild/start?region=us-west-2

填写名称

点击右边的创建项目按钮,填写项目名称

选择构建来源

这里选code commit,然后选择对应的仓库和分支

选择环境

本文是前端项目,选择了有nodejs18对应的ec2环境

对应环境的runtime关系可以看这里, https://docs.aws.amazon.com/codebuild/latest/userguide/available-runtimes.html

不同环境的价格,详见: https://aws.amazon.com/cn/codebuild/pricing/

比如需要nodejs 18版本,只能选对应的几种环境,

但是lambda在使用过程中npm i报错,后面使用ec2后成功,

设置构建脚本

可以用yaml文件,也可以在线写

build脚本的规范,详见: https://docs.aws.amazon.com/zh_cn/codebuild/latest/userguide/build-spec-ref.html

version: 0.2

#env:
#variables:
# key: "value"
# key: "value"
#parameter-store:
# key: "value"
# key: "value"
#secrets-manager:
# key: secret-id:json-key:version-stage:version-id
# key: secret-id:json-key:version-stage:version-id
#exported-variables:
# - variable
# - variable
#git-credential-helper: yes
#batch:
#fast-fail: true
#build-list:
#build-matrix:
#build-graph:
phases:
  install:
    runtime-versions:
      nodejs: 18
    commands:
  pre_build:
    commands:
      - npm i
      - npx nx reset
  build:
    commands:
      - npm run release:online
  #post_build:
  #commands:
  # - command
  # - command
#reports:
#report-name-or-arn:
#files:
# - location
# - location
#base-directory: location
#discard-paths: yes
#file-format: JunitXml | CucumberJson
artifacts:
  files:
    - packages/_server/**/*
  name: server-$CODEBUILD_BUILD_ID-$(date +%Y-%m-%d)
#cache:
#paths:
# - paths

选择构件存储位置

这里是aws s3,创建教程: https://blog.insistime.com/aws-s3

构件打包为zip自动传到s3对应的位置

日志,一般选择cloud watch,如下

至此,一个aws code build项目创建成功

【开始构建】

创建好后,点击开始构建就会进行构建的过程

点击后可以看到对应的构建过程的日志

相关推荐

AWS-CertificateManager

【前言】 AWS Certificate Manager是AWS的证书托管系统, 如果配合AWS的LB一起使用,可以免费申请通配证书 【申请证书】 地址: https://uswest2.console.aws.amazon.com/acm/home?region=uswest2/welcome 点

AWS-CodeArtifact

【前言】 AWS CodeArtifact是托管构件的存储库,可以托管npm,maven等 【创建】 地址: https://uswest2.console.aws.amazon.com/codesuite/codeartifact/start?region=uswest2点击右侧的创建存储库按钮开

AWS-CodeCommit

【前言】 aws提供了类似github,gitlab的代码托管服务, 目前有一个场景是将内网gitlab的代码下载到aws ec2上, 之前的方案是将gitlab代码镜像到github, 见:Gitlab代码同步到Github 实测效果,github在阿里云ecs上访问经常会timeout, 阿里云

AWS-CodeDeploy

【前言】 aws code deploy,代码部署 【创建】 地址 https://uswest2.console.aws.amazon.com/codesuite/codedeploy/start?region=uswest2创建应用 填写名称和目标后创建, 这里的应用程序下可以创建很多部署组,

AWS-CodePipeline

【前言】 aws code pipeline是流水线工具, 类似开源的jenkins,以及个云的流水线工具 【创建流水线】 地址: https://uswest2.console.aws.amazon.com/codesuite/codepipeline/start?region=uswest2 s

AWS-使用Lambda@edge转换Cloudfront图片

【前言】 国内云厂商存放图片的oss或者cos可以很方便的转换图片格式和大小等, 一般都是在url后拼接转换参数即可, AWS居然没有提供这个服务,需要自己写lambda@edge函数实现, 本文完整的介绍下如果使用lambda@edge实现图片转换的功能。 【参考】 开始是想找github开源方案

AWS-Route53

【前言】 AWS Route 53是DNS解析服务, 本文将一个之前腾讯云托管的域名转移到AWS Route53上。 【AWS Route 53创建应用】 地址:https://useast1.console.aws.amazon.com/route53/v2/home?region=uswest2

AWS-S3

【前言】 aws s3是类似阿里云oss,腾讯云cos的存储服务 【创建存储桶】 地址: https://s3.console.aws.amazon.com/s3/getstarted?region=useast1 点击右侧的创建存储桶按钮, 填写名称,选择区域, acl默认禁用 公共访问和版本控制

Gitlab代码同步到Github

【背景】 公司的代码一直在内网的gitlab上, 包括日常的代码提交,代码review,代码项目管理,人员管理等, 目前有新业务需要部署到海外aws上, 也就是说需要从海外aws上拉取国内阿里云内网的gitlab代码, 常见的几个方案 1. 国内gitlab到国外aws走跨境专线 2. 手动将代码同

Mac安装mysql

【前言】 mac安装mysql 【下载】 下载社区版本的mysql, 地址: https://dev.mysql.com/downloads/mysql/ 这里选的mac arm dmg版本, 会跳转到新页面,选择直接下载, 【安装】 双击dmg, 双击pkg安装mysql, 按提示点击继续, 选择

Mac上多开微信客户端

【前言】 在日常生活中很多人有多个微信, 手机端的话通过两个手机或者安卓手机多开应用可以实现多开微信, Mac电脑端如何多开微信呢, 常见的方法是一个客户端, 一个网页端: https://wx.qq.com/ , 但是网页端体验肯定没有客户端好, 本文介绍下如何在Mac上多开微信客户端。 【创建快

Mysql授权某个IP访问

© 2026 vincentqiao.com . 保留所有权利。