From 4ec704d51230ed32f7162c4fa8d24d3acd1eae00 Mon Sep 17 00:00:00 2001 From: Oliver Runge Date: Sun, 2 Jan 2022 14:30:34 +0100 Subject: [PATCH] Add size-only flag to aws s3 sync This will avoid re-upload if the file size doesn't change. Currently the check on mtime is not very useful, as the local time of last modification never will match the upload mtime on S3. A better/safer mechanism would be to hash the file content and store it as e-tag. These tickets discuss such a feature, but it isn't implemented yet: - https://github.com/aws/aws-cli/issues/599 - https://github.com/aws/aws-cli/pull/575 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fc0e055e8..ec8f93c10 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ prod-frontend-release: yarn shadow-cljs release frontend --config-merge '$(PROD_CONFIG)' prod-frontend-deploy: check-before-deploy-frontend prod-frontend-release - aws --profile heraldry-serverless s3 sync --acl public-read $(PROD_FRONTEND_RELEASE_DIR) s3://cdn.heraldry.digital + aws --profile heraldry-serverless s3 sync --size-only --acl public-read $(PROD_FRONTEND_RELEASE_DIR) s3://cdn.heraldry.digital aws --profile heraldry-serverless s3 cp --acl public-read $(PROD_FRONTEND_RELEASE_DIR)/index.html s3://cdn.heraldry.digital/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html git tag $(shell date +"deploy-frontend-%Y-%m-%d_%H-%M-%S") ./invalidate-distribution.sh cdn.heraldry.digital @@ -63,7 +63,7 @@ staging-frontend-release: yarn shadow-cljs release frontend --config-merge '$(STAGING_CONFIG)' --config-merge '{:output-dir "./build/staging/js/generated"}' staging-frontend-deploy: staging-frontend-release - aws --profile heraldry-serverless s3 sync --acl public-read $(STAGING_FRONTEND_RELEASE_DIR) s3://cdn.staging.heraldry.digital + aws --profile heraldry-serverless s3 sync --size-only --acl public-read $(STAGING_FRONTEND_RELEASE_DIR) s3://cdn.staging.heraldry.digital aws --profile heraldry-serverless s3 cp --acl public-read $(STAGING_FRONTEND_RELEASE_DIR)/index.html s3://cdn.staging.heraldry.digital/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html ./invalidate-distribution.sh cdn.staging.heraldry.digital