@tiddh/brave-vue 1.92.41 → 1.92.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +2 -0
- package/.dockerignore +15 -0
- package/.eslintrc.js +17 -0
- package/.gitignore +29 -0
- package/.storybook/main.js +64 -0
- package/.vscode/settings.json +3 -0
- package/Dockerfile +13 -0
- package/_ddh/deploy/Jenkinsfile +166 -0
- package/_ddh/deploy/Release +2 -0
- package/_ddh/deploy/extractArtifact.ps1 +16 -0
- package/_ddh/infrastructure/terraform/README.md +33 -0
- package/_ddh/infrastructure/terraform/modules/deploy/buildspec.yml +68 -0
- package/_ddh/infrastructure/terraform/modules/deploy/codebuild.tf +59 -0
- package/_ddh/infrastructure/terraform/modules/deploy/codedeploy.tf +64 -0
- package/_ddh/infrastructure/terraform/modules/deploy/iam.tf +42 -0
- package/_ddh/infrastructure/terraform/modules/deploy/main.tf +6 -0
- package/_ddh/infrastructure/terraform/modules/deploy/policies/codebuild-assume-role.json +12 -0
- package/_ddh/infrastructure/terraform/modules/deploy/policies/codebuild-role-policy.json +57 -0
- package/_ddh/infrastructure/terraform/modules/deploy/policies/codedeploy-assume-role-policy.json +12 -0
- package/_ddh/infrastructure/terraform/modules/deploy/variables.tf +93 -0
- package/_ddh/infrastructure/terraform/modules/main/alb.tf +80 -0
- package/_ddh/infrastructure/terraform/modules/main/auto-scaling.tf +28 -0
- package/_ddh/infrastructure/terraform/modules/main/cloudwatchlog.tf +11 -0
- package/_ddh/infrastructure/terraform/modules/main/ecr.tf +37 -0
- package/_ddh/infrastructure/terraform/modules/main/ecs-services.tf +51 -0
- package/_ddh/infrastructure/terraform/modules/main/ecs-tasks.tf +36 -0
- package/_ddh/infrastructure/terraform/modules/main/iam.tf +40 -0
- package/_ddh/infrastructure/terraform/modules/main/main.tf +4 -0
- package/_ddh/infrastructure/terraform/modules/main/outputs.tf +65 -0
- package/_ddh/infrastructure/terraform/modules/main/policies/ecs-autoscaling-assume-role-policy.json +12 -0
- package/_ddh/infrastructure/terraform/modules/main/policies/ecs-autoscaling-role-policy.json +18 -0
- package/_ddh/infrastructure/terraform/modules/main/policies/ecs-task-assume-role-policy.json +13 -0
- package/_ddh/infrastructure/terraform/modules/main/security-groups.tf +27 -0
- package/_ddh/infrastructure/terraform/modules/main/tasks/web-task-definition.json +29 -0
- package/_ddh/infrastructure/terraform/modules/main/variables.tf +100 -0
- package/_ddh/infrastructure/terraform/stages/10-shared/codedeploy.tf +6 -0
- package/_ddh/infrastructure/terraform/stages/10-shared/main.tf +4 -0
- package/_ddh/infrastructure/terraform/stages/10-shared/outputs.tf +9 -0
- package/_ddh/infrastructure/terraform/stages/10-shared/state.tf +11 -0
- package/_ddh/infrastructure/terraform/stages/10-shared/variables.tf +14 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/100-main/main.tf +37 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/100-main/outputs.tf +74 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/100-main/state.tf +11 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/100-main/variables.tf +61 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/200-deploy/main.tf +57 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/200-deploy/state.tf +11 -0
- package/_ddh/infrastructure/terraform/stages/30-prod/200-deploy/variables.tf +34 -0
- package/appspec.yaml +9 -0
- package/babel.config.js +5 -0
- package/build/rollup.config.js +198 -0
- package/dist/brave-vue.esm.js +10 -6
- package/dist/brave-vue.min.js +1 -1
- package/dist/brave-vue.ssr.js +23 -19
- package/dist/src/Preview/Preview.vue +12 -8
- package/dist/src/Preview/PreviewWithTools.vue +19 -3
- package/dist/src/Preview.vue +12 -8
- package/dist/src/PreviewWithTools.vue +19 -3
- package/dist/src/components/Preview/Preview.vue +12 -8
- package/dist/src/components/Preview/PreviewWithTools.vue +19 -3
- package/dist/src/serve-dev.js +8 -0
- package/dist/src/serve-dev.vue +17 -0
- package/docker-compose.yml +8 -0
- package/gulpfile.js +88 -0
- package/package.json +2 -2
- package/public/favicon.ico +0 -0
- package/public/images/mochila-biscoito.png +0 -0
- package/public/images/mochila-biscoito.webp +0 -0
- package/public/images/mochila-biscoito@2x.png +0 -0
- package/public/images/mochila-biscoito@2x.webp +0 -0
- package/public/images/mochila-fofilha.png +0 -0
- package/public/images/mochila-fofilha.webp +0 -0
- package/public/images/mochila-fofilha@2x.png +0 -0
- package/public/images/mochila-fofilha@2x.webp +0 -0
- package/public/index.html +22 -0
- package/src/App.vue +28 -0
- package/src/assets/logo.png +0 -0
- package/src/components/Avatar/Avatar.stories.js +214 -0
- package/src/components/Avatar/Avatar.vue +481 -0
- package/src/components/Avatar/elements/CategoryCustomizations.vue +506 -0
- package/src/components/Avatar/elements/CustomizationPanel.vue +1092 -0
- package/src/components/Avatar/elements/CustomizationPreview.vue +152 -0
- package/src/components/Avatar/elements/CustomizationView.vue +828 -0
- package/src/components/Avatar/elements/ToggleColor.vue +109 -0
- package/src/components/Avatar/elements/ToggleSubcategory.vue +152 -0
- package/src/components/Avatar/elements/scss/avatar-vfx.scss +717 -0
- package/src/components/Avatar/utils.js +149 -0
- package/src/components/Buttons/Button.vue +1706 -0
- package/src/components/Buttons/ButtonWithIcon.stories.js +133 -0
- package/src/components/Buttons/Ghost.stories.js +78 -0
- package/src/components/Buttons/Link.stories.js +77 -0
- package/src/components/Buttons/Loading.stories.js +108 -0
- package/src/components/Buttons/Primary.stories.js +79 -0
- package/src/components/Buttons/ProgressiveLoading.stories.js +95 -0
- package/src/components/Buttons/Secondary.stories.js +79 -0
- package/src/components/Card/Card.stories.js +38 -0
- package/src/components/Card/Card.vue +119 -0
- package/src/components/Card/CardLink.stories.js +45 -0
- package/src/components/Card/CardLink.vue +233 -0
- package/src/components/Card/CardOption.stories.js +48 -0
- package/src/components/Card/CardOption.vue +274 -0
- package/src/components/Form/Checkbox.stories.js +40 -0
- package/src/components/Form/Checkbox.vue +205 -0
- package/src/components/Form/GenderSelect.stories.js +53 -0
- package/src/components/Form/GenderSelect.vue +289 -0
- package/src/components/Form/Input.stories.js +546 -0
- package/src/components/Form/Input.vue +943 -0
- package/src/components/Form/InputAddress.vue +695 -0
- package/src/components/Form/InputAddressBilling.vue +633 -0
- package/src/components/Form/InputAddressNumber.vue +634 -0
- package/src/components/Form/InputCardNumber.vue +653 -0
- package/src/components/Form/InputEdit.vue +235 -0
- package/src/components/Form/InputEmail.vue +240 -0
- package/src/components/Form/InputName.vue +352 -0
- package/src/components/Form/Options.stories.js +94 -0
- package/src/components/Form/Options.vue +398 -0
- package/src/components/Form/Picker.stories.js +44 -0
- package/src/components/Form/PickerBirthday.vue +631 -0
- package/src/components/Form/Radius.stories.js +49 -0
- package/src/components/Form/Radius.vue +160 -0
- package/src/components/Form/Select.stories.js +98 -0
- package/src/components/Form/Select.vue +404 -0
- package/src/components/Form/SelectBirthday.vue +419 -0
- package/src/components/Form/TextArea.stories.js +52 -0
- package/src/components/Form/TextArea.vue +274 -0
- package/src/components/HelloWorld.vue +59 -0
- package/src/components/Icons/Icon.stories.js +1155 -0
- package/src/components/Icons/Icon.vue +363 -0
- package/src/components/Icons/IconBrand.js +232 -0
- package/src/components/Icons/IconBrand.vue +359 -0
- package/src/components/Images/Images.stories.js +26 -0
- package/src/components/Images/Images.vue +51 -0
- package/src/components/Loading/Loading.stories.js +26 -0
- package/src/components/Loading/Loading.vue +103 -0
- package/src/components/Modal/Modal.stories.js +51 -0
- package/src/components/Modal/Modal.vue +406 -0
- package/src/components/Navigation/Breadcrumb.stories.js +82 -0
- package/src/components/Navigation/Breadcrumb.vue +191 -0
- package/src/components/Navigation/Stepper.stories.js +82 -0
- package/src/components/Navigation/Stepper.vue +183 -0
- package/src/components/Navigation/Tabs.stories.js +84 -0
- package/src/components/Navigation/Tabs.vue +192 -0
- package/src/components/Navigation/TopBar.stories.js +69 -0
- package/src/components/Navigation/TopBar.vue +64 -0
- package/src/components/Preview/BottomBar.vue +237 -0
- package/src/components/Preview/Preview.stories.js +307 -0
- package/src/components/Preview/Preview.vue +1066 -0
- package/src/components/Preview/PreviewFull.vue +188 -0
- package/src/components/Preview/PreviewMobile.vue +1219 -0
- package/src/components/Preview/PreviewTools.vue +2870 -0
- package/src/components/Preview/PreviewWithTools.vue +365 -0
- package/src/components/Preview/css/flipbook.scss +166 -0
- package/src/components/Preview/js/language.json +95 -0
- package/src/components/Preview/js/turn.min.js +68 -0
- package/src/components/Preview/js/zoom.min.js +26 -0
- package/src/components/Tooltip/Tooltip.stories.js +51 -0
- package/src/components/Tooltip/Tooltip.vue +185 -0
- package/src/components/Typography/Caption.stories.js +28 -0
- package/src/components/Typography/Caption.vue +63 -0
- package/src/components/Typography/Heading.stories.js +34 -0
- package/src/components/Typography/Heading.vue +103 -0
- package/src/components/Typography/Paragraph.stories.js +34 -0
- package/src/components/Typography/Paragraph.vue +85 -0
- package/src/components/Utils/Feedback.vue +320 -0
- package/src/components/Utils/HR.vue +68 -0
- package/src/components/Utils/Spinner.vue +89 -0
- package/src/components/Utils/feedback.stories.js +44 -0
- package/src/components/Utils/hr-primary.stories.js +38 -0
- package/src/components/Utils/spinner.stories.js +23 -0
- package/src/components/index.js +37 -0
- package/src/entry.js +36 -0
- package/src/main.js +8 -0
- package/src/serve-dev.js +8 -0
- package/src/serve-dev.vue +17 -0
- package/src/styles/styles.scss +5 -0
- package/src/wrapper.js +70 -0
- package/taskdef.json +39 -0
- package/yarn-error.log +16060 -0
- package/yarn.lock +15925 -0
- package/dist/src/Preview/TopBar.vue +0 -115
- package/dist/src/components/Preview/TopBar.vue +0 -115
package/.browserslistrc
ADDED
package/.dockerignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
'extends': [
|
|
7
|
+
'plugin:vue/essential',
|
|
8
|
+
'eslint:recommended'
|
|
9
|
+
],
|
|
10
|
+
parserOptions: {
|
|
11
|
+
parser: 'babel-eslint'
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
15
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
|
|
16
|
+
}
|
|
17
|
+
}
|
package/.gitignore
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
node_modules
|
|
3
|
+
.out
|
|
4
|
+
/.out
|
|
5
|
+
/dist
|
|
6
|
+
/storybook-static
|
|
7
|
+
icon
|
|
8
|
+
/icon
|
|
9
|
+
|
|
10
|
+
# local env files
|
|
11
|
+
.env.local
|
|
12
|
+
.env.*.local
|
|
13
|
+
|
|
14
|
+
# Log files
|
|
15
|
+
npm-debug.log*
|
|
16
|
+
yarn-debug.log*
|
|
17
|
+
yarn-error.log*
|
|
18
|
+
|
|
19
|
+
# Editor directories and files
|
|
20
|
+
.idea
|
|
21
|
+
.vscode
|
|
22
|
+
*.suo
|
|
23
|
+
*.ntvs*
|
|
24
|
+
*.njsproj
|
|
25
|
+
*.sln
|
|
26
|
+
*.sw?
|
|
27
|
+
|
|
28
|
+
.terraform
|
|
29
|
+
.terraform.lock.hcl
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
console.log(path.resolve(__dirname, "../"));
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
stories: ["../src/**/*.stories.(js|mdx)"],
|
|
6
|
+
addons: [
|
|
7
|
+
//"@storybook/addon-docs",
|
|
8
|
+
"@storybook/addon-actions",
|
|
9
|
+
"@storybook/addon-links",
|
|
10
|
+
"@storybook/addon-knobs/register",
|
|
11
|
+
"@storybook/addon-viewport/register",
|
|
12
|
+
],
|
|
13
|
+
webpackFinal: (config) => {
|
|
14
|
+
config.module.rules.push({
|
|
15
|
+
test: /\.scss$/,
|
|
16
|
+
use: [
|
|
17
|
+
"vue-style-loader",
|
|
18
|
+
"css-loader",
|
|
19
|
+
{
|
|
20
|
+
loader: "sass-loader",
|
|
21
|
+
options: {
|
|
22
|
+
additionalData: `
|
|
23
|
+
@import "src/styles/styles.scss";
|
|
24
|
+
`,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
include: path.resolve(__dirname, "../"), //AQUI REFERENCIA A ROOT
|
|
29
|
+
});
|
|
30
|
+
config.resolve.extensions.push(".scss");
|
|
31
|
+
|
|
32
|
+
// Add a new rule to handle the font files
|
|
33
|
+
config.module.rules.push({
|
|
34
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
35
|
+
use: [
|
|
36
|
+
{
|
|
37
|
+
loader: "file-loader",
|
|
38
|
+
options: {
|
|
39
|
+
name: "[name].[ext]",
|
|
40
|
+
outputPath: "fonts/",
|
|
41
|
+
publicPath: "../fonts/",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
config.module.rules.unshift({
|
|
48
|
+
test: /\.svg$/,
|
|
49
|
+
loader: "html-loader",
|
|
50
|
+
include: path.resolve(__dirname, "../"),
|
|
51
|
+
});
|
|
52
|
+
config.resolve.extensions.push(".svg");
|
|
53
|
+
|
|
54
|
+
config.module.rules.forEach(function (data, key) {
|
|
55
|
+
if (data.test.toString().indexOf("svg|") >= 0) {
|
|
56
|
+
config.module.rules[key].test =
|
|
57
|
+
/\.(ico|jpg|jpeg|png|gif|cur|ani)(\?.*)?$/;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return config;
|
|
63
|
+
},
|
|
64
|
+
};
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
@Library('jenkins-shared-libs') _
|
|
2
|
+
import br.com.dentrodahistoria.Utilities
|
|
3
|
+
final Utilities utilities = new Utilities(this)
|
|
4
|
+
|
|
5
|
+
pipeline {
|
|
6
|
+
|
|
7
|
+
agent any
|
|
8
|
+
|
|
9
|
+
parameters {
|
|
10
|
+
choice( name: 'AreYouSure', choices: ['no','yes'], description: 'Publish brave storybook?' )
|
|
11
|
+
//credentials name: 'awsCodeBuildCredentials' defaultValue: 'aws_code_build_br', description: 'AWS CodeBuild Credentials' credentialType: 'CodeBuildCredentials'
|
|
12
|
+
//credentials name: 'awsCredentials' defaultValue: 'aws_br', description: 'AWS Credentials' credentialType: 'com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl'
|
|
13
|
+
//string name: 'gitBranch', trim: true, defaultValue: 'master', description: 'Git branch do projeto'
|
|
14
|
+
//string name: 'stage', trim: true, defaultValue: 'prod', description: 'Stage Name'
|
|
15
|
+
//string name: 'codeDeployApplicationName', trim: true, defaultValue: '', description: 'CodeDeploy application name'
|
|
16
|
+
//string name: 'codeDeployDeploymentGroupName', trim: true, defaultValue: '', description: 'CodeDeploy deployment group name'
|
|
17
|
+
//string name: 'codeBuildProjectName', trim: true, defaultValue: '', description: 'CodeBuild project name'
|
|
18
|
+
//string name: 'ecsClusterArn', trim: true, defaultValue: '', description: 'ECS cluster arn'
|
|
19
|
+
//string name: 'ecsServiceName', trim: true, defaultValue: '', description: 'ECS service name'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
stages
|
|
23
|
+
{
|
|
24
|
+
stage('pre-conditions')
|
|
25
|
+
{
|
|
26
|
+
steps
|
|
27
|
+
{
|
|
28
|
+
script
|
|
29
|
+
{
|
|
30
|
+
// get username
|
|
31
|
+
def buildUsername = ''
|
|
32
|
+
try {
|
|
33
|
+
// requires plugin: https://plugins.jenkins.io/build-user-vars-plugin
|
|
34
|
+
wrap([$class: 'BuildUser']) {
|
|
35
|
+
buildUsername = "${env.BUILD_USER}"
|
|
36
|
+
}
|
|
37
|
+
} catch (err) {
|
|
38
|
+
echo "Falha ao obter BuildUser"
|
|
39
|
+
echo err.getMessage()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
env.buildUsername = buildUsername;
|
|
43
|
+
|
|
44
|
+
script {
|
|
45
|
+
env.gitCommit = bat(returnStdout: true, script: """ \
|
|
46
|
+
@echo off
|
|
47
|
+
git log -n 1 --pretty=format:%%h
|
|
48
|
+
""").trim()
|
|
49
|
+
|
|
50
|
+
echo "Last commit: ${env.gitCommit}"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if ("${params.AreYouSure}" == "yes")
|
|
54
|
+
{
|
|
55
|
+
utilities.notifySlack('STARTED')
|
|
56
|
+
echo "OK"
|
|
57
|
+
}
|
|
58
|
+
else
|
|
59
|
+
{
|
|
60
|
+
currentBuild.result = 'ABORTED'
|
|
61
|
+
error('stopping build')
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
stage('log')
|
|
69
|
+
{
|
|
70
|
+
steps
|
|
71
|
+
{
|
|
72
|
+
script
|
|
73
|
+
{
|
|
74
|
+
// echo all parameters
|
|
75
|
+
params.each { key, value ->
|
|
76
|
+
echo "${key} = ${value}"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
stage('build')
|
|
83
|
+
{
|
|
84
|
+
steps
|
|
85
|
+
{
|
|
86
|
+
script
|
|
87
|
+
{
|
|
88
|
+
awsCodeBuild(
|
|
89
|
+
projectName: "${params.codeBuildProjectName}",
|
|
90
|
+
credentialsType: 'jenkins',
|
|
91
|
+
credentialsId: "${params.awsCodeBuildCredentials}",
|
|
92
|
+
region: 'us-east-1',
|
|
93
|
+
sourceControlType: 'project',
|
|
94
|
+
sourceVersion: "${params.gitBranch}",
|
|
95
|
+
downloadArtifactsRelativePath: '.artifacts/',
|
|
96
|
+
downloadArtifacts: 'true'
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def result = bat(script: """
|
|
100
|
+
@echo off
|
|
101
|
+
powershell -f \".\\_ddh\\deploy\\extractArtifact.ps1\"
|
|
102
|
+
""", returnStdout: true)
|
|
103
|
+
|
|
104
|
+
def resultJson = readJSON text: "${result}"
|
|
105
|
+
|
|
106
|
+
// resolve paths
|
|
107
|
+
env.appspecPath = resultJson.appspecPath
|
|
108
|
+
env.taskdefPath = resultJson.taskdefPath
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
stage('codedeploy')
|
|
114
|
+
{
|
|
115
|
+
steps
|
|
116
|
+
{
|
|
117
|
+
script
|
|
118
|
+
{
|
|
119
|
+
bat (script: """\
|
|
120
|
+
aws ecs deploy \
|
|
121
|
+
--codedeploy-application \"${params.codeDeployApplicationName}\" \
|
|
122
|
+
--codedeploy-deployment-group \"${params.codeDeployDeploymentGroupName}\" \
|
|
123
|
+
--service \"${params.ecsServiceName}\" \
|
|
124
|
+
--cluster \"${params.ecsClusterArn}\" \
|
|
125
|
+
--task-definition \"${env.taskdefPath.replace("\\", "\\\\")}\" \
|
|
126
|
+
--codedeploy-appspec \"${env.appspecPath.replace("\\", "\\\\")}\" \
|
|
127
|
+
--profile \"${params.awsProfile}\"
|
|
128
|
+
""")
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
post
|
|
135
|
+
{
|
|
136
|
+
always
|
|
137
|
+
{
|
|
138
|
+
script
|
|
139
|
+
{
|
|
140
|
+
dir ('.artifacts') {
|
|
141
|
+
deleteDir()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (currentBuild.result != 'SUCCESS' && currentBuild.result != 'FAILURE')
|
|
145
|
+
{
|
|
146
|
+
utilities.notifySlack('ABORTED')
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
success
|
|
151
|
+
{
|
|
152
|
+
script
|
|
153
|
+
{
|
|
154
|
+
utilities.notifySlack(currentBuild.result)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
failure
|
|
158
|
+
{
|
|
159
|
+
script
|
|
160
|
+
{
|
|
161
|
+
utilities.notifySlack(currentBuild.result)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# find latest artifact build
|
|
2
|
+
$artifact = (Get-ChildItem ".artifacts/" -Recurse -Filter "*.zip" | Sort {$_.LastWriteTime} | select -last 1)
|
|
3
|
+
$zipFilePath = $artifact.FullName
|
|
4
|
+
$path = $artifact.Directory.FullName
|
|
5
|
+
|
|
6
|
+
# extract
|
|
7
|
+
#[System.IO.Compression.ZipFile]::ExtractToDirectory($zipFilePath, $path)
|
|
8
|
+
Expand-Archive -Path $zipFilePath -DestinationPath $path -Force
|
|
9
|
+
|
|
10
|
+
$result = @{
|
|
11
|
+
appspecPath = Join-Path $path -ChildPath "appspec.yaml"
|
|
12
|
+
taskdefPath = Join-Path $path -ChildPath "taskdef.json"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
# echo json
|
|
16
|
+
ConvertTo-Json $result -Compress
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Infraestrutura
|
|
2
|
+
|
|
3
|
+
Utilizamos o Terraform para gerenciamento da infraestrutura.
|
|
4
|
+
|
|
5
|
+
Há dois módulos compartilhados:
|
|
6
|
+
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
Responsável pela criação dos recursos principais (security groups, tasks, services, etc)
|
|
10
|
+
|
|
11
|
+
- deploy
|
|
12
|
+
|
|
13
|
+
Responsável pela criação dos recursos de CI/CD (codebuild / codedeploy)
|
|
14
|
+
|
|
15
|
+
## Criação dos ambientes
|
|
16
|
+
|
|
17
|
+
Na pasta `stages` temos as configurações para cada ambiente.
|
|
18
|
+
|
|
19
|
+
O stage `10-shared` contém recursos que serão compartilhados por todos os ambientes (e.g. ALB, CodeDeploy, etc).
|
|
20
|
+
|
|
21
|
+
Ordem de criação dos recursos:
|
|
22
|
+
|
|
23
|
+
- `stages/10-shared`
|
|
24
|
+
- `stages/{stage}`
|
|
25
|
+
- `stages/{stage}/100-main`
|
|
26
|
+
- `stages/{stage}/200-deploy`
|
|
27
|
+
|
|
28
|
+
Comandos:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
terraform init
|
|
32
|
+
terraform apply
|
|
33
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
version: 0.2
|
|
2
|
+
|
|
3
|
+
env:
|
|
4
|
+
parameter-store:
|
|
5
|
+
dockerhub_username: "/ddh/dockerhub-username"
|
|
6
|
+
dockerhub_password: "/ddh/dockerhub-pwd"
|
|
7
|
+
|
|
8
|
+
phases:
|
|
9
|
+
pre_build:
|
|
10
|
+
commands:
|
|
11
|
+
- aws --version
|
|
12
|
+
# preparing env vars
|
|
13
|
+
- REPOSITORY_URI=${repository_url}
|
|
14
|
+
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
|
|
15
|
+
- echo $COMMIT_HASH
|
|
16
|
+
- IMAGE_TAG=$${COMMIT_HASH:=latest}
|
|
17
|
+
- echo $IMAGE_TAG
|
|
18
|
+
# ecr login
|
|
19
|
+
- echo Logging in to Amazon ECR...
|
|
20
|
+
- aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${repository_registry_id}.dkr.ecr.${region}.amazonaws.com
|
|
21
|
+
# docker hub login
|
|
22
|
+
- echo Login docker hub
|
|
23
|
+
- docker login -u $dockerhub_username -p $dockerhub_password
|
|
24
|
+
build:
|
|
25
|
+
commands:
|
|
26
|
+
- echo Build started on `date`
|
|
27
|
+
# preparing "taskdef.json"
|
|
28
|
+
- echo Preparing taskdef.json
|
|
29
|
+
# -- escape pois o arn possui barras (/) que atrapalham o "sed"
|
|
30
|
+
#- sed -i 's/<ACCOUNT_ID>/'${account_id}'/g' taskdef.json
|
|
31
|
+
- sed -i 's/<CONTAINER_PORT>/'${web_container_port}'/g' taskdef.json
|
|
32
|
+
- ESCAPED_TEMP_VAR=$(printf '%s\n' "${iam_ecs_task_execution_role_arn}" | sed -e 's/[]\/$*.^[]/\\&/g');
|
|
33
|
+
- sed -i 's/<EXECUTION_ROLE_ARN>/'$ESCAPED_TEMP_VAR'/g' taskdef.json
|
|
34
|
+
- sed -i 's/<FAMILY>/'${task_definition_family_web}'/g' taskdef.json
|
|
35
|
+
- ESCAPED_TEMP_VAR=$(printf '%s\n' "$REPOSITORY_URI" | sed -e 's/[]\/$*.^[]/\\&/g');
|
|
36
|
+
- sed -i 's/<IMAGE>/'$ESCAPED_TEMP_VAR:$IMAGE_TAG'/g' taskdef.json
|
|
37
|
+
- ESCAPED_TEMP_VAR=$(printf '%s\n' "${ecs_log_group}" | sed -e 's/[]\/$*.^[]/\\&/g');
|
|
38
|
+
- sed -i 's/<LOG_GROUP>/'$ESCAPED_TEMP_VAR'/g' taskdef.json
|
|
39
|
+
- sed -i 's/<REGION>/'${region}'/g' taskdef.json
|
|
40
|
+
- sed -i 's/<STAGE>/'${stage}'/g' taskdef.json
|
|
41
|
+
- ESCAPED_TEMP_VAR=$(printf '%s\n' "${iam_ecs_task_role_arn}" | sed -e 's/[]\/$*.^[]/\\&/g');
|
|
42
|
+
- sed -i 's/<TASK_ROLE_ARN>/'$ESCAPED_TEMP_VAR'/g' taskdef.json
|
|
43
|
+
# preparing "appspec.yaml"
|
|
44
|
+
- echo Preparing appspec.yaml
|
|
45
|
+
# -- escape pois o arn possui barras (/) que atrapalham o "sed"
|
|
46
|
+
- ESCAPED_TEMP_VAR=$(printf '%s\n' "${task_definition_arn_web}" | sed -e 's/[]\/$*.^[]/\\&/g');
|
|
47
|
+
- sed -i 's/<TASK_DEFINITION>/'$ESCAPED_TEMP_VAR'/g' appspec.yaml
|
|
48
|
+
- sed -i 's/<CONTAINER_PORT>/'${web_container_port}'/g' appspec.yaml
|
|
49
|
+
# docker build
|
|
50
|
+
- echo Building the Docker image...
|
|
51
|
+
- cd $CODEBUILD_SRC_DIR
|
|
52
|
+
- docker build -t $REPOSITORY_URI:latest .
|
|
53
|
+
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
|
|
54
|
+
post_build:
|
|
55
|
+
commands:
|
|
56
|
+
- echo Build completed on `date`
|
|
57
|
+
# testing build
|
|
58
|
+
- echo Testing build succeeded
|
|
59
|
+
- test "$CODEBUILD_BUILD_SUCCEEDING" = "1"
|
|
60
|
+
# docker push
|
|
61
|
+
- echo Pushing the Docker images...
|
|
62
|
+
- docker push $REPOSITORY_URI:latest
|
|
63
|
+
- docker push $REPOSITORY_URI:$IMAGE_TAG
|
|
64
|
+
artifacts:
|
|
65
|
+
files:
|
|
66
|
+
- appspec.yaml
|
|
67
|
+
- taskdef.json
|
|
68
|
+
name: "builds/$(echo $ENV_PREFIX)/$(date +%F-%H-%M-%S)-$(echo $COMMIT_HASH).zip"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# load codebuild buildspec
|
|
2
|
+
data "template_file" "buildspec" {
|
|
3
|
+
template = file("${path.module}/buildspec.yml")
|
|
4
|
+
|
|
5
|
+
vars = {
|
|
6
|
+
account_id = data.aws_caller_identity.current.account_id
|
|
7
|
+
ecs_log_group = var.ecs_log_group
|
|
8
|
+
iam_ecs_task_role_arn = var.iam_ecs_task_role_arn
|
|
9
|
+
iam_ecs_task_execution_role_arn = var.iam_ecs_task_execution_role_arn
|
|
10
|
+
region = var.aws_region
|
|
11
|
+
repository_registry_id = var.repository_registry_id
|
|
12
|
+
repository_url = var.repository_url
|
|
13
|
+
stage = var.stage
|
|
14
|
+
task_definition_arn_web = var.ecs_task_definition_arn_web
|
|
15
|
+
task_definition_family_web = var.ecs_task_definition_family_web
|
|
16
|
+
web_container_port = var.web_container_port
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# codebuild project
|
|
21
|
+
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codebuild_project
|
|
22
|
+
resource "aws_codebuild_project" "web" {
|
|
23
|
+
name = "${local.prefix}-web"
|
|
24
|
+
description = "Build ${local.prefix} web project"
|
|
25
|
+
build_timeout = "10" # in minutes
|
|
26
|
+
service_role = aws_iam_role.codebuild.arn
|
|
27
|
+
|
|
28
|
+
artifacts {
|
|
29
|
+
type = "S3"
|
|
30
|
+
location = var.s3_bucket_artifacts_name
|
|
31
|
+
packaging = "ZIP"
|
|
32
|
+
override_artifact_name = true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
source {
|
|
36
|
+
auth {
|
|
37
|
+
resource = var.bitbucket_connetion_arn
|
|
38
|
+
type= "OAUTH"
|
|
39
|
+
}
|
|
40
|
+
type = "BITBUCKET"
|
|
41
|
+
location = var.source_location
|
|
42
|
+
buildspec = data.template_file.buildspec.rendered
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
source_version = var.source_branch_name
|
|
46
|
+
|
|
47
|
+
environment {
|
|
48
|
+
compute_type = "BUILD_GENERAL1_SMALL"
|
|
49
|
+
// https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
|
|
50
|
+
image = "aws/codebuild/standard:5.0"
|
|
51
|
+
type = "LINUX_CONTAINER"
|
|
52
|
+
privileged_mode = true
|
|
53
|
+
|
|
54
|
+
environment_variable {
|
|
55
|
+
name = "ENV_PREFIX"
|
|
56
|
+
value = local.prefix
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# code deploy group (blue green)
|
|
2
|
+
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group
|
|
3
|
+
resource "aws_codedeploy_deployment_group" "main" {
|
|
4
|
+
app_name = var.codedeploy_app_name
|
|
5
|
+
deployment_group_name = var.stage
|
|
6
|
+
deployment_config_name = "CodeDeployDefault.ECSAllAtOnce"
|
|
7
|
+
service_role_arn = aws_iam_role.codedeploy.arn
|
|
8
|
+
depends_on = [aws_iam_role.codedeploy]
|
|
9
|
+
|
|
10
|
+
auto_rollback_configuration {
|
|
11
|
+
enabled = true
|
|
12
|
+
events = ["DEPLOYMENT_FAILURE"]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
blue_green_deployment_config {
|
|
16
|
+
deployment_ready_option {
|
|
17
|
+
action_on_timeout = "CONTINUE_DEPLOYMENT"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
terminate_blue_instances_on_deployment_success {
|
|
21
|
+
action = "TERMINATE"
|
|
22
|
+
termination_wait_time_in_minutes = var.codedeploy_termination_wait_time_in_minutes
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
deployment_style {
|
|
27
|
+
deployment_option = "WITH_TRAFFIC_CONTROL"
|
|
28
|
+
deployment_type = "BLUE_GREEN"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ecs_service {
|
|
32
|
+
cluster_name = var.ecs_cluster_name
|
|
33
|
+
service_name = var.ecs_service_name_web
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
load_balancer_info {
|
|
37
|
+
target_group_pair_info {
|
|
38
|
+
prod_traffic_route {
|
|
39
|
+
listener_arns = [var.alb_listener_https_arn]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
target_group {
|
|
43
|
+
name = var.alb_target_group_web_blue_name
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
target_group {
|
|
47
|
+
name = var.alb_target_group_web_green_name
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
trigger_configuration {
|
|
53
|
+
trigger_name = "${var.codedeploy_app_name}-${var.stage}-notification"
|
|
54
|
+
trigger_target_arn = var.codedeploy_sns_topic_arn
|
|
55
|
+
trigger_events = [
|
|
56
|
+
"DeploymentStart",
|
|
57
|
+
"DeploymentSuccess",
|
|
58
|
+
"DeploymentFailure",
|
|
59
|
+
"DeploymentStop",
|
|
60
|
+
"DeploymentReady",
|
|
61
|
+
"DeploymentRollback"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# *** ****************************************
|
|
2
|
+
# *** Code build
|
|
3
|
+
# *** ****************************************
|
|
4
|
+
|
|
5
|
+
# code build role
|
|
6
|
+
resource "aws_iam_role" "codebuild" {
|
|
7
|
+
name = "${local.prefix}-codebuild-role"
|
|
8
|
+
assume_role_policy = file("${path.module}/policies/codebuild-assume-role.json")
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# load policy data
|
|
12
|
+
data "template_file" "codebuild_role_policy" {
|
|
13
|
+
template = file("${path.module}/policies/codebuild-role-policy.json")
|
|
14
|
+
|
|
15
|
+
vars = {
|
|
16
|
+
aws_region = var.aws_region
|
|
17
|
+
aws_s3_bucket_name = var.s3_bucket_artifacts_name
|
|
18
|
+
stage = var.stage
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# code build role policy
|
|
23
|
+
resource "aws_iam_role_policy" "codebuild_policy" {
|
|
24
|
+
name = "${local.prefix}-codebuild-role-policy"
|
|
25
|
+
role = aws_iam_role.codebuild.id
|
|
26
|
+
policy = data.template_file.codebuild_role_policy.rendered
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# *** ****************************************
|
|
30
|
+
# *** CodeDeploy
|
|
31
|
+
# *** ****************************************
|
|
32
|
+
|
|
33
|
+
# codedeploy role
|
|
34
|
+
resource "aws_iam_role" "codedeploy" {
|
|
35
|
+
name = "${local.prefix}-codedeploy-role"
|
|
36
|
+
assume_role_policy = file("${path.module}/policies/codedeploy-assume-role-policy.json")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_iam_role_policy_attachment" "codedeploy" {
|
|
40
|
+
policy_arn = "arn:aws:iam::aws:policy/AWSCodeDeployRoleForECS"
|
|
41
|
+
role = aws_iam_role.codedeploy.name
|
|
42
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Version": "2012-10-17",
|
|
3
|
+
"Statement": [
|
|
4
|
+
{
|
|
5
|
+
"Effect": "Allow",
|
|
6
|
+
"Resource": [
|
|
7
|
+
"*"
|
|
8
|
+
],
|
|
9
|
+
"Action": [
|
|
10
|
+
"logs:CreateLogGroup",
|
|
11
|
+
"logs:CreateLogStream",
|
|
12
|
+
"logs:PutLogEvents",
|
|
13
|
+
"ecr:GetAuthorizationToken",
|
|
14
|
+
"ecr:InitiateLayerUpload",
|
|
15
|
+
"ecr:UploadLayerPart",
|
|
16
|
+
"ecr:CompleteLayerUpload",
|
|
17
|
+
"ecr:BatchCheckLayerAvailability",
|
|
18
|
+
"ecr:PutImage",
|
|
19
|
+
"ecs:DescribeTaskDefinition",
|
|
20
|
+
"ecs:RunTask",
|
|
21
|
+
"iam:PassRole"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"Effect":"Allow",
|
|
26
|
+
"Action": [
|
|
27
|
+
"s3:GetObject",
|
|
28
|
+
"s3:GetObjectVersion",
|
|
29
|
+
"s3:GetBucketVersioning",
|
|
30
|
+
"s3:List*",
|
|
31
|
+
"s3:PutObject"
|
|
32
|
+
],
|
|
33
|
+
"Resource": [
|
|
34
|
+
"arn:aws:s3:::${aws_s3_bucket_name}",
|
|
35
|
+
"arn:aws:s3:::${aws_s3_bucket_name}/*"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"Effect": "Allow",
|
|
40
|
+
"Action": [
|
|
41
|
+
"codestar-connections:UseConnection",
|
|
42
|
+
"codestar-connections:GetConnection",
|
|
43
|
+
"codestar-connections:ListConnections"
|
|
44
|
+
],
|
|
45
|
+
"Resource": "*"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"Effect": "Allow",
|
|
49
|
+
"Action": [
|
|
50
|
+
"ssm:GetParameters"
|
|
51
|
+
],
|
|
52
|
+
"Resource": [
|
|
53
|
+
"arn:aws:ssm:${aws_region}:*:parameter/ddh/dockerhub-*"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|