AWS S3
要继续部署到 S3,我们将安装这些插件:
- ember-cli-deploy-s3-index :它使用修订信息将 index.html 上传到 S3,并激活它
- ember-cli-deploy-s3 :它将资产(js,css 和其他媒体文件)上传到 S3
由于它们是 Ember 插件,你可以通过运行以下命令轻松安装
ember install ember-cli-deploy-s3-index
ember install ember-cli-deploy-s3
之后你需要的是配置 deploy.js 文件,该文件应位于/ config 文件夹下:
// config/deploy.js
module.exports = function(deployTarget) {
var ENV = {
build: {
environment: deployTarget
},
'revision-data': {
type: 'git-commit'
},
's3-index': {
accessKeyId: process.env['S3_ACCESS_KEY'],
secretAccessKey: process.env['S3_SECRET_ACCESS_KEY'],
bucket: "your-app-deployment-bucket",
region: "YOUR REGISION",
allowOverwrite: true // if you want to overwrite index file if not change it to false
},
's3': {
accessKeyId: process.env['S3_ACCESS_KEY'],
secretAccessKey: process.env['S3_SECRET_ACCESS_KEY'],
bucket: "your-app-deployment-bucket",
region: "YOUR REGISION",
}
};
return ENV;
};
请注意,我们在 config 中使用了环境变量。如果需要从文件中读取配置,也可以返回使用 ENV
对象解析的 promise。以下是在 deploy.js 文件中定义不同环境的示例:
if (deployTarget === 'development') {
ENV.build.environment = 'development';
// configure other plugins for development deploy target here
}
if (deployTarget === 'staging') {
ENV.build.environment = 'production';
// configure other plugins for staging deploy target here
}
if (deployTarget === 'production') {
ENV.build.environment = 'production';
// configure other plugins for production deploy target here
}
最后,你可以轻松运行以下命令进行部署
ember deploy [YOUR APP ENVIRONMENT] //e.g-> ember deploy production or ember deploy staging
如果你想查看可以运行的详细信息:
ember deploy production --verbose --activate=true