-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cicd/replace test env wuth s3 (#323)
* rework pipeline and test envs to s3 Co-authored-by: sostrovskyi <sostrovskyi>
- Loading branch information
Showing
8 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
pipeline { | ||
agent { | ||
node { | ||
label 'jenkins-main' | ||
} | ||
} | ||
parameters { | ||
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'dev', name: 'sha1', type: 'PT_BRANCH', quickFilterEnabled: true | ||
} | ||
stages { | ||
stage('Web: build') { | ||
steps { | ||
script { | ||
env.VERSION = sh script: "cat version.json | jq .version | tr -d '\"\n'", returnStdout: true | ||
currentBuild.displayName = "#${BUILD_NUMBER}_deploy_${VERSION}" | ||
dir('web') { | ||
sh "make build ENV=dev REACT_APP_ISDOCKEREXT=false" | ||
} | ||
} | ||
} | ||
} | ||
stage('Web: deploy') { | ||
steps { | ||
script { | ||
env.BUCKET_NAME = 'app-' + env.VERSION.replaceAll("[^a-zA-Z0-9 ]+","-") | ||
dir('web') { | ||
def status = sh(script: "aws s3api head-bucket --bucket ${BUCKET_NAME}", returnStatus: true) | ||
if (status == 0) { | ||
echo 'Bucket already exists. Just syncing.' | ||
sh "aws s3 sync build/ s3://${BUCKET_NAME}" | ||
} else { | ||
sh """ | ||
aws s3api create-bucket --bucket ${BUCKET_NAME} --region eu-west-2 --acl public-read --create-bucket-configuration LocationConstraint=eu-west-2 | ||
aws s3 website s3://${BUCKET_NAME} --index-document index.html --error-document error.html | ||
sed 's/BUCKET_NAME/${BUCKET_NAME}/g' ../.ci/s3/policy.json.template > policy.json | ||
aws s3api put-bucket-policy --bucket ${BUCKET_NAME} --policy file://policy.json | ||
aws s3 sync build/ s3://${BUCKET_NAME} | ||
sed "s/BUCKET_NAME/\$BUCKET_NAME/g" ../.ci/nginx/proxy.s3.conf.template >> /opt/nginx/s3-proxy.conf | ||
docker restart nginx-test-app-gosh-sh | ||
""" | ||
} | ||
} | ||
timeout(15) { | ||
waitUntil { | ||
def r = sh script: "sleep 10 && curl -s --retry-connrefused --retry 100 --retry-delay 5 https://${BUCKET_NAME}.gosh.sh > /dev/null", returnStatus: true | ||
return r == 0 | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
server_names_hash_bucket_size 1024; | ||
server { listen 80 default_server; return 404;} | ||
|
||
server { | ||
|
||
listen 80; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
server { | ||
|
||
listen 80; | ||
server_name BUCKET_NAME.gosh.sh; | ||
|
||
location / { | ||
proxy_pass http://BUCKET_NAME.s3-website.eu-west-2.amazonaws.com; | ||
proxy_intercept_errors on; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "PublicRead", | ||
"Effect": "Allow", | ||
"Principal": "*", | ||
"Action": [ | ||
"s3:GetObject", | ||
"s3:GetObjectVersion" | ||
], | ||
"Resource": "arn:aws:s3:::BUCKET_NAME/*" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters