forked from fluent/fluent-bit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish and Verify image using CI/CD Pipeline (fluent#19)
Publish and Verify image using CI/CD Pipeline
- Loading branch information
1 parent
319f00d
commit e295703
Showing
5 changed files
with
199 additions
and
0 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,21 @@ | ||
version: 0.2 | ||
phases: | ||
install: | ||
runtime-versions: | ||
golang: 1.12 | ||
pre_build: | ||
commands: | ||
- echo Building the AWS for Fluent Bit image | ||
build: | ||
commands: | ||
# Command to build your project | ||
- make release | ||
|
||
# List the docker images | ||
- docker images | ||
|
||
# Push the image to ECR in the same account and same region the pipeline is hosted. | ||
- ecs-cli push amazon/aws-for-fluent-bit-test:latest | ||
artifacts: | ||
files: | ||
- '**/*' |
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,28 @@ | ||
version: 0.2 | ||
phases: | ||
install: | ||
runtime-versions: | ||
golang: 1.12 | ||
pre_build: | ||
commands: | ||
- echo Running the integration test | ||
build: | ||
commands: | ||
# Get the default credentials and set as environment variables | ||
- 'CREDS=`curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`' | ||
- 'export AWS_ACCESS_KEY_ID=`echo $CREDS | jq -r .AccessKeyId`' | ||
- 'export AWS_SECRET_ACCESS_KEY=`echo $CREDS | jq -r .SecretAccessKey`' | ||
- 'export AWS_SESSION_TOKEN=`echo $CREDS | jq -r .Token`' | ||
|
||
# Pull the image that we built and pushed in the `Build` stage | ||
- 'ecs-cli pull amazon/aws-for-fluent-bit-test:latest' | ||
- 'docker tag ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:latest amazon/aws-for-fluent-bit:latest' | ||
|
||
# List the images to do a double check | ||
- 'docker images' | ||
|
||
# Command to run the integration test | ||
- 'make integ' | ||
artifacts: | ||
files: | ||
- '**/*' |
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,25 @@ | ||
version: 0.2 | ||
phases: | ||
install: | ||
runtime-versions: | ||
golang: 1.12 | ||
pre_build: | ||
commands: | ||
- echo Publish the image to DockerHub | ||
build: | ||
commands: | ||
# Pull the image that we built and pushed in the `Build` stage | ||
- 'ecs-cli pull amazon/aws-for-fluent-bit-test:latest' | ||
- 'docker tag ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:latest amazon/aws-for-fluent-bit:latest' | ||
|
||
# List the docker images | ||
- docker images | ||
|
||
# Push the image to dockerhub | ||
- 'DRY_RUN="false" ./scripts/publish.sh cicd-publish dockerhub' | ||
|
||
# Pull the image from dockerhub and verify | ||
- './scripts/publish.sh cicd-verify dockerhub' | ||
artifacts: | ||
files: | ||
- '**/*' |
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,48 @@ | ||
version: 0.2 | ||
phases: | ||
install: | ||
runtime-versions: | ||
golang: 1.12 | ||
pre_build: | ||
commands: | ||
- echo Publish the image to ECR | ||
build: | ||
commands: | ||
# Pull the image that we built and pushed in the `Build` stage | ||
- 'ecs-cli pull amazon/aws-for-fluent-bit-test:latest' | ||
- 'docker tag ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:latest amazon/aws-for-fluent-bit:latest' | ||
|
||
# List the docker images | ||
- docker images | ||
|
||
# Assume role to publish, get the credentials, and set them as environment variables | ||
- | | ||
if [ "${PUBLISH_ROLE_ARN}" != "" ]; then | ||
CREDS=`aws sts assume-role --role-arn ${PUBLISH_ROLE_ARN} --role-session-name ${REGION_TO_PUSH} --region ${REGION_TO_PUSH}` | ||
export AWS_ACCESS_KEY_ID=`echo $CREDS | jq -r .Credentials.AccessKeyId` | ||
export AWS_SECRET_ACCESS_KEY=`echo $CREDS | jq -r .Credentials.SecretAccessKey` | ||
export AWS_SESSION_TOKEN=`echo $CREDS | jq -r .Credentials.SessionToken` | ||
fi | ||
# Push the image to ECR | ||
- './scripts/publish.sh cicd-publish ${REGION_TO_PUSH}' | ||
|
||
# Nullify the temporary credentials for the assumed role to publish | ||
- | | ||
if [ "${PUBLISH_ROLE_ARN}" != "" ]; then | ||
export AWS_ACCESS_KEY_ID= | ||
export AWS_SECRET_ACCESS_KEY= | ||
export AWS_SESSION_TOKEN= | ||
fi | ||
# Assume role to verify, get the credentials, and set them as environment variables | ||
- CREDS=`aws sts assume-role --role-arn ${VERIFY_ROLE_ARN} --role-session-name ${REGION_TO_PUSH} --region ${REGION_TO_PUSH}` | ||
- export AWS_ACCESS_KEY_ID=`echo $CREDS | jq -r .Credentials.AccessKeyId` | ||
- export AWS_SECRET_ACCESS_KEY=`echo $CREDS | jq -r .Credentials.SecretAccessKey` | ||
- export AWS_SESSION_TOKEN=`echo $CREDS | jq -r .Credentials.SessionToken` | ||
|
||
# Verify from the verification account | ||
- './scripts/publish.sh cicd-verify ${REGION_TO_PUSH}' | ||
artifacts: | ||
files: | ||
- '**/*' |
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