diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 218f123..fd5e01f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,27 @@ jobs: run: pnpm install --no-frozen-lockfile - name: Build Astro application (Development) - run: pnpm run build + run: | + echo "🏗️ Building Astro application..." + pnpm run build + + # Create checksum of build artifacts for verification + find ./dist -type f -name "*.css" -o -name "*.js" -o -name "*.mjs" | sort | xargs sha256sum > build-manifest.txt + echo "📄 Build manifest created:" + cat build-manifest.txt + + # Verify critical files exist + if [ ! -f "./dist/server/entry.mjs" ]; then + echo "❌ Server entry point missing" + exit 1 + fi + + if [ ! -d "./dist/client/_astro" ]; then + echo "❌ Client assets missing" + exit 1 + fi + + echo "✅ Build verification complete" env: PUBLIC_API_URL: ${{ env.API_URL }} PUBLIC_SITE_URL: ${{ env.SITE_URL }} @@ -74,9 +94,39 @@ jobs: - name: Build and push Docker image (Dev) run: | - # Build image with build args + echo "🐳 Building Docker image..." + + # Store the GitHub Actions build for comparison + cp -r ./dist ./dist-github + + # Build Docker image (will rebuild inside container) docker build --build-arg PUBLIC_API_URL=${{ env.API_URL }} --build-arg PUBLIC_SITE_URL=${{ env.SITE_URL }} -t ${{ env.REGISTRY_HOSTNAME }}/${{ env.GCP_PROJECT_ID }}/cloud-run-source-deploy/${{ env.SERVICE_NAME }}:${{ github.sha }} -t ${{ env.REGISTRY_HOSTNAME }}/${{ env.GCP_PROJECT_ID }}/cloud-run-source-deploy/${{ env.SERVICE_NAME }}:latest-dev . + # Extract build from Docker image to verify consistency + docker create --name temp-container ${{ env.REGISTRY_HOSTNAME }}/${{ env.GCP_PROJECT_ID }}/cloud-run-source-deploy/${{ env.SERVICE_NAME }}:${{ github.sha }} + docker cp temp-container:/app/dist ./dist-docker + docker rm temp-container + + # Compare the builds + echo "🔍 Comparing GitHub Actions build vs Docker build..." + find ./dist-github -type f -name "*.css" -o -name "*.js" -o -name "*.mjs" | sort | sed 's|./dist-github|./dist|' | xargs -I {} sh -c 'sha256sum ./dist-github/$(echo {} | sed "s|./dist/||")' > github-manifest.txt + find ./dist-docker -type f -name "*.css" -o -name "*.js" -o -name "*.mjs" | sort | sed 's|./dist-docker|./dist|' | xargs -I {} sh -c 'sha256sum ./dist-docker/$(echo {} | sed "s|./dist/||")' > docker-manifest.txt + + if ! diff github-manifest.txt docker-manifest.txt; then + echo "⚠️ WARNING: Docker build produced different artifacts!" + echo "GitHub build files:" + ls -la ./dist-github/client/_astro/ + echo "Docker build files:" + ls -la ./dist-docker/client/_astro/ + echo "Using Docker build (this is what runs in production)" + else + echo "✅ Docker build matches GitHub Actions build perfectly" + fi + + # Use Docker build artifacts for bucket upload + rm -rf ./dist + mv ./dist-docker ./dist + # Push both tags docker push ${{ env.REGISTRY_HOSTNAME }}/${{ env.GCP_PROJECT_ID }}/cloud-run-source-deploy/${{ env.SERVICE_NAME }}:${{ github.sha }} docker push ${{ env.REGISTRY_HOSTNAME }}/${{ env.GCP_PROJECT_ID }}/cloud-run-source-deploy/${{ env.SERVICE_NAME }}:latest-dev @@ -105,13 +155,26 @@ jobs: - name: Upload static assets to Cloud Storage (Dev) run: | - # Only upload if Cloud Run deployment succeeded - echo "Uploading static assets after successful deployment..." + echo "📦 Uploading static assets (EXACT same files from deployed Docker image)..." + + # Verify we're using Docker build artifacts + if [ ! -f "./dist/server/entry.mjs" ]; then + echo "❌ Docker build artifacts not found!" + exit 1 + fi + echo "✅ Using Docker build artifacts (matches deployed container)" # Upload Astro static assets if [ -d "./dist/client/_astro" ]; then + echo "📄 Files being uploaded:" + ls -la ./dist/client/_astro/ + gsutil -m rsync -r -d ./dist/client/_astro gs://${{ env.BUCKET_NAME }}/_astro/ echo "✅ Uploaded _astro assets" + + # Verify upload + echo "📄 Files in bucket after upload:" + gsutil ls gs://${{ env.BUCKET_NAME }}/_astro/ else echo "❌ No _astro directory found" exit 1 @@ -129,7 +192,7 @@ jobs: gsutil -m setmeta -h "Cache-Control:public, max-age=86400" \ "gs://${{ env.BUCKET_NAME }}/images/**" || true - echo "✅ Static assets uploaded successfully" + echo "🎉 Static assets uploaded successfully and verified!" # Production deployment deploy-prod: diff --git a/Dockerfile b/Dockerfile index 6fc7964..40a112f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,12 @@ ENV PUBLIC_SITE_URL=$PUBLIC_SITE_URL # Build the application RUN pnpm run build +# Verify the build completed correctly +RUN ls -la ./dist && \ + test -f "./dist/server/entry.mjs" || (echo "❌ Server entry missing" && exit 1) && \ + test -d "./dist/client/_astro" || (echo "❌ Client assets missing" && exit 1) && \ + echo "✅ Build verification complete" + # Production stage FROM node:20-alpine AS runner diff --git a/public/images/README.md b/public/images/README.md new file mode 100644 index 0000000..3acbdb9 --- /dev/null +++ b/public/images/README.md @@ -0,0 +1,7 @@ +# Test Images + +This directory contains test images to verify the load balancer routing for `/images/*` paths. + +- `logo.svg` - A simple logo SVG +- `test-image.svg` - A blue rectangle with text +- All images should be served from Cloud Storage via the load balancer \ No newline at end of file diff --git a/public/images/logo.svg b/public/images/logo.svg new file mode 100644 index 0000000..793ec96 --- /dev/null +++ b/public/images/logo.svg @@ -0,0 +1,4 @@ + + + LOGO + \ No newline at end of file diff --git a/public/images/test-image.svg b/public/images/test-image.svg new file mode 100644 index 0000000..8a6aae3 --- /dev/null +++ b/public/images/test-image.svg @@ -0,0 +1,4 @@ + + + Test Image + \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 8707d64..3892ceb 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -6,6 +6,19 @@ import FD from "@firstdate/sample.astro"; --- +
+

FreshmenFest 2025

+ + +
+ Logo +
+ +
+ Test Image +
+
+