46 lines
1.6 KiB
Bash
Executable File
46 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# --- Configuration -----------------------------------------------------------
|
|
# Provide your own values via environment variables or edit the defaults below.
|
|
BUCKET_NAME="${BUCKET_NAME:-lenssim-static-prod}"
|
|
CLOUDFRONT_ID="${CLOUDFRONT_ID:-EM92WLNGPGOVA}"
|
|
CLOUDFRONT_DOMAIN="${CLOUDFRONT_DOMAIN:-d3z407nghipey.cloudfront.net}"
|
|
AWS_REGION="${AWS_REGION:-eu-central-1}"
|
|
|
|
if [[ -z "${BUCKET_NAME}" ]]; then
|
|
echo "❌ Please set BUCKET_NAME (env var or inside deploy.sh) before deploying." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "${CLOUDFRONT_ID}" == "YOUR_CLOUDFRONT_DIST_ID" || -z "${CLOUDFRONT_ID}" ]]; then
|
|
echo "❌ Please set CLOUDFRONT_ID (env var or inside deploy.sh) before deploying." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "🚀 Building LensSim SPA..."
|
|
npm run build
|
|
|
|
echo "📦 Syncing hashed assets to s3://${BUCKET_NAME}..."
|
|
aws s3 sync dist/ s3://${BUCKET_NAME} \
|
|
--delete \
|
|
--exclude "index.html" \
|
|
--cache-control "public, max-age=31536000, immutable"
|
|
|
|
echo "🗂 Uploading index.html with no-cache headers..."
|
|
aws s3 cp dist/index.html s3://${BUCKET_NAME}/index.html \
|
|
--cache-control "no-cache, no-store, must-revalidate" \
|
|
--content-type "text/html"
|
|
|
|
echo "🔄 Creating CloudFront invalidation for shell files..."
|
|
aws cloudfront create-invalidation \
|
|
--distribution-id "${CLOUDFRONT_ID}" \
|
|
--paths "/" "/index.html" \
|
|
--output text > /dev/null
|
|
|
|
echo
|
|
echo "✅ Deployment finished."
|
|
echo "🌐 CloudFront URL: https://${CLOUDFRONT_DOMAIN}/"
|
|
echo "🪣 S3 Website (if enabled): http://${BUCKET_NAME}.s3-website.${AWS_REGION}.amazonaws.com/"
|
|
echo "⏱️ Note: CloudFront edge caches can take a few minutes to refresh."
|