Created
May 11, 2022 11:58
-
-
Save shollingsworth/df26e2af55ae913e53f6b42b2925ce21 to your computer and use it in GitHub Desktop.
sync frontend files to cloudfront enabled s3 bucket and invalidate cache
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| TAG="cf-frontend:latest" | |
| DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| BUCKET="cf-bucket" | |
| CF_DIST_ID="d-xxxxxxxxxxxx" | |
| FRONTEND_DIR="${DIR}/../frontend" | |
| pushd "${FRONTEND_DIR}" | |
| docker build -t "${TAG}" \ | |
| -f "../localdev/frontend-build.Dockerfile" \ | |
| . | |
| docker run --rm -it \ | |
| -v "${FRONTEND_DIR}:/frontend" \ | |
| --workdir /frontend \ | |
| "${TAG}" \ | |
| quasar build | |
| aws s3 sync \ | |
| --delete \ | |
| --acl public-read \ | |
| "${FRONTEND_DIR}/dist/spa" \ | |
| "s3://${BUCKET}" | |
| aws cloudfront create-invalidation --distribution-id "${CF_DIST_ID}" --paths "/*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment