Skip to content

Commit

Permalink
Put our cache cleaner in ECR (#681)
Browse files Browse the repository at this point in the history
* Add an ECR repo for the cache cleaner

* Add make tasks for the cache cleaner

* Default to 'latest' for non-existent release files
  • Loading branch information
alexwlchan authored and kenoir committed Jul 20, 2017
1 parent a9a6f0a commit 46a1bc4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ docker-build-terraform:
docker-build-gatling:
docker build ./docker/gatling --tag gatling_ci

## Build the image for the cache cleaner
docker-build-cache_cleaner:
docker build ./efs_cache_cleaner --tag cache_cleaner

## Build the image for the cache cleaner
docker-deploy-cache_cleaner: docker-build-cache_cleaner
./scripts/deploy_docker_to_aws.py --project=cache_cleaner --infra-bucket=$(INFRA_BUCKET)


install-docker-build-deps:
pip3 install --upgrade boto3 docker docopt
Expand Down
12 changes: 9 additions & 3 deletions scripts/deploy_docker_to_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@

# Get the release ID (which is the image tag)
release_file = os.path.join(ROOT, '.releases', project)
tag = open(release_file).read().strip()
release_file_exists = True
try:
tag = open(release_file).read().strip()
except FileNotFoundError:
release_file_exists = False
tag = 'latest'
docker_image = '%s:%s' % (project, tag)

# Look up the URI of our ECR repo -- this is needed for authentication
Expand Down Expand Up @@ -69,5 +74,6 @@
docker_client.images.remove(image=renamed_image_tag)

# Finally, upload the release ID string to S3.
print('*** Uploading release ID to S3')
bucket.upload_file(Filename=release_file, Key='releases/%s' % project)
if release_file_exists:
print('*** Uploading release ID to S3')
bucket.upload_file(Filename=release_file, Key='releases/%s' % project)
5 changes: 5 additions & 0 deletions terraform/ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ module "ecr_repository_loris" {
source = "./ecr"
name = "loris"
}

module "ecr_repository_cache_cleaner" {
source = "./ecr"
name = "cache_cleaner"
}

0 comments on commit 46a1bc4

Please sign in to comment.