-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set lifecycle rules #9
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ orbs: | |
# https://circleci.com/orbs/registry/orb/circleci/aws-ecr | ||
# required environment variables: | ||
# https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables | ||
aws-ecr: circleci/aws-ecr@6.15.3 | ||
aws-ecr: circleci/aws-ecr@8.1.2 | ||
|
||
workflows: | ||
version: 2 | ||
|
@@ -28,10 +28,47 @@ workflows: | |
# | ||
# The AWS ECR repo name, example: remind101/acme-inc | ||
repo: "$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" | ||
# tags for this image, comma separated. | ||
tag: "latest,$CIRCLE_BRANCH,$CIRCLE_SHA1" | ||
# tags for this image, comma separated. A composite of branch+sha1 is | ||
# added so the lifecycle rule (below) can filter images beginning | ||
# with "master" or "main" to avoid applying aggressive rules. | ||
tag: "latest,$CIRCLE_BRANCH,$CIRCLE_SHA1,$CIRCLE_BRANCH-$CIRCLE_BUILD_NUM" | ||
# create the AWS ECR repo if it does not exist already. | ||
create-repo: true | ||
# Set the lifecycle for the repo. Note that this setting expects | ||
# an inline policy, even if it's named "-path". | ||
# The max count for master and main is set to 8,000, 80% of the} | ||
# available space in the repo, in order to safeguard against removing | ||
# running images after aggressive rebuilding of the master branch. | ||
lifecycle-policy-path: > | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation says this should be a path, not the actual content. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! But it's a lie. I started adding a file as in https://github.com/remind101/r101-api/pull/16623/files#diff-2c27a3138e2c83cb750d9a8a3b415799e8f3806ae6bd8a9d06a6abb23e018d36 (only left there for dev purposes) only to get After my initial wtf moment, my suspects were confirmed when I tried the current approach and bingo! got Trust no one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WTF lol. Well, at least it would be good to have a comment to explain that.
🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean with "at least"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added comment |
||
{ | ||
"rules": [ | ||
{ | ||
"rulePriority": 1, | ||
"description": "Keep latest master image", | ||
"selection": { | ||
"tagStatus": "tagged", | ||
"tagPrefixList": ["master", "main"], | ||
"countType": "imageCountMoreThan", | ||
"countNumber": 8000 | ||
}, | ||
"action": { | ||
"type": "expire" | ||
} | ||
}, | ||
{ | ||
"rulePriority": 2, | ||
"description": "Expire all images older than 90 days.", | ||
"selection": { | ||
"countType": "sinceImagePushed", | ||
"countNumber": 90, | ||
"countUnit": "days" | ||
}, | ||
"action": { | ||
"type": "expire" | ||
} | ||
} | ||
] | ||
} | ||
# provide the aws-ecr context (environment variables) to push docker_image into ecr. | ||
# https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables | ||
context: aws-ecr | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd still want to keep the commit SHA in the prefixed tag, because it's nice to have that info embedded and also would make it easier to transition to something other than CircleCI without causing conflicts.