18 Commits

Author SHA1 Message Date
Matt
bfb163c21a Remove Formspree and secure Wren API token
Some checks failed
Build and Push Docker Images / docker (push) Failing after 1m54s
Security & Cleanup Changes:
1. Removed NEXT_PUBLIC_WREN_API_TOKEN from frontend (security risk)
2. Removed Formspree references (no longer needed)
3. Wren API token now lives in backend only (runtime configurable)
4. Added NocoDB env vars to frontend for admin portal server-side API

Changes:
- Dockerfile: Removed Formspree and NEXT_PUBLIC_WREN_API_TOKEN build args
- CI/CD: Updated build-args to only include necessary variables
- Frontend should call backend /api/wren/* endpoints
- Backend handles Wren API with WREN_API_TOKEN (can change anytime!)

Benefits:
 API token no longer exposed in browser
 Can change Wren token without rebuilding images
 Cleaner build process
 Removed unused Formspree dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 10:50:33 +01:00
Matt
bfe5897232 Fix NEXT_PUBLIC environment variables for production builds
Some checks failed
Build and Push Docker Images / docker (push) Failing after 1m56s
Problem:
- NEXT_PUBLIC_* variables must be baked into Next.js build at BUILD TIME
- Setting them in docker-compose is too late (bundle already built)
- This caused "NEXT_PUBLIC_WREN_API_TOKEN is undefined" errors in production

Solution:
1. Updated Dockerfile to accept ARG values for all NEXT_PUBLIC_* variables
2. Set ARGs as ENV variables before npm run build (lines 15-26)
3. Updated CI/CD workflow to pass build-args from Gitea secrets/vars
4. Variables are now baked into the image during build

Next Steps:
1. Add these secrets to Gitea repository settings:
   - NEXT_PUBLIC_WREN_API_TOKEN
   - NEXT_PUBLIC_FORMSPREE_CONTACT_ID
   - NEXT_PUBLIC_FORMSPREE_OFFSET_ID
   - NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY

2. Add this variable to Gitea repository settings:
   - NEXT_PUBLIC_API_BASE_URL

3. Next push will build image with variables baked in
4. Can simplify docker-compose (remove NEXT_PUBLIC_* from web service)

Files Changed:
- Dockerfile: Added ARG and ENV declarations before build step
- .gitea/workflows/build-deploy.yml: Added build-args to frontend image build

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 10:47:27 +01:00
Matt
ec0c8a2fbc Fix Docker build cache size issue by using mode=min
All checks were successful
Build and Push Docker Images / docker (push) Successful in 1m1s
Change buildcache from mode=max to mode=min to reduce cache layer size
and fix "413 Request Entity Too Large" error when pushing to Gitea registry.

mode=min only caches layers likely to be reused, significantly reducing
the cache size while maintaining build performance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 17:51:43 +01:00
Matt
bc9e2d3782 Implement comprehensive Stripe security fixes and production deployment
All checks were successful
Build and Push Docker Images / docker (push) Successful in 1m22s
CRITICAL SECURITY FIXES:
- Add webhook secret validation to prevent signature bypass
- Implement idempotency protection across all webhook handlers
- Add atomic database updates to prevent race conditions
- Improve CORS security with origin validation and logging
- Remove .env from git tracking to protect secrets

STRIPE INTEGRATION:
- Add support for checkout.session.expired webhook event
- Add Stripe publishable key to environment configuration
- Fix webhook handlers with proper idempotency checks
- Update Order model with atomic updatePaymentAndStatus method
- Add comprehensive logging for webhook processing

DEPLOYMENT ARCHITECTURE:
- Split into two Docker images (frontend-latest, backend-latest)
- Update CI/CD to build separate frontend and backend images
- Configure backend on port 3801 (internal 3001)
- Add production-ready docker-compose.yml
- Remove redundant docker-compose.portainer.yml
- Update nginx configuration for both frontend and backend

DOCUMENTATION:
- Add PRODUCTION-SETUP.md with complete deployment guide
- Add docs/stripe-security-fixes.md with security audit details
- Add docs/stripe-checkout-sessions.md with integration docs
- Add docs/stripe-webhooks.md with webhook configuration
- Update .env.example with all required variables including Stripe publishable key

CONFIGURATION:
- Consolidate to single .env.example template
- Update .gitignore to protect all .env variants
- Add server/Dockerfile for backend container
- Update DEPLOYMENT.md with new architecture

🔒 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 12:18:57 +01:00
Matt
077deb4194 Remove container specification - use runner's default ubuntu-latest
All checks were successful
Build and Push Docker Image / docker (push) Successful in 3m31s
Match working workflow pattern from other server.
Let runner provide Docker environment directly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:28:21 +01:00
Matt
b9c03fa87e Remove driver specification from Buildx setup
Some checks failed
Build and Push Docker Image / docker (push) Failing after 11s
Let Buildx use default driver with --privileged container.
The 'docker' driver caused endpoint property errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:27:34 +01:00
Matt
aec179ec49 Remove duplicate Docker socket mount from workflow
Some checks failed
Build and Push Docker Image / docker (push) Failing after 12s
Runner already mounts /var/run/docker.sock automatically.
Keep only --privileged flag to allow socket access.

Fixes: Error response from daemon: Duplicate mount point

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:26:49 +01:00
Matt
41f8fc1c76 Fix Docker socket permission issue in CI/CD workflow
Some checks failed
Build and Push Docker Image / docker (push) Failing after 1s
- Add --privileged flag and explicit Docker socket mount to container
- Configure Buildx to use 'docker' driver instead of 'docker-container'
- This avoids nested container permission issues while using full Ubuntu image

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:25:30 +01:00
Matt
189255a7d8 Use repository variables for registry configuration
Some checks failed
Build and Push Docker Image / docker (push) Failing after 14s
Match the working workflow pattern from other server by using
repository variables instead of hardcoded values:

- REGISTRY_HOST (code.puffinoffset.com)
- REGISTRY_USERNAME (matt)
- IMAGE_NAME (puffin-app)
- REGISTRY_TOKEN (secret with write:package permission)

This makes the workflow portable and matches the proven
working configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:22:32 +01:00
Matt
7b9901174e Use full Ubuntu image with Docker pre-installed
Some checks failed
Build and Push Docker Image / docker (push) Failing after 10m58s
Based on Zen multi-model consensus analysis:

Root cause: act_runner v0.2.13+3 maps ubuntu-latest to bare
ubuntu:22.04 which lacks Docker CLI. Newer runners use full images.

Solution: Override job container to use ghcr.io/catthehacker/ubuntu:full-22.04
which includes Docker, Buildx, Node.js, and standard CI tools.

This is the recommended approach from act_runner maintainers for
GitHub Actions compatibility.

Consensus from Gemini-2.5-pro and o3 models.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:08:41 +01:00
Matt
47fb07a7d2 Use proven Gitea Actions pattern from working workflow
Some checks failed
Build and Push Docker Image / docker (push) Failing after 1m32s
Switch to the pattern that works on other server:
- Run directly on ubuntu-latest (no container)
- Use docker/login-action@v3
- Use docker/setup-buildx-action@v3
- Use docker/build-push-action@v6

This matches the working workflow from another repository
and should work with the Gitea runner configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:58:49 +01:00
Matt
5a2a1c47da Replace actions/checkout with manual git clone
Some checks failed
Build and Push Docker Image / build (push) Failing after 2s
The docker:dind image doesn't include Node.js which is required
by actions/checkout@v4. Use manual git commands instead.

Changes:
- Install git via apk (Alpine package manager)
- Clone repository directly
- Checkout specific commit SHA

This approach works with docker:dind's minimal Alpine base.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:57:58 +01:00
Matt
683843458e Use Docker-in-Docker container for builds
Some checks failed
Build and Push Docker Image / build (push) Failing after 9s
Root cause: act_runner provides minimal environment without sudo
or Docker CLI. Cannot install packages in workflow.

Solution: Use docker:24-dind container which includes Docker CLI
and daemon. Runs with --privileged to allow nested containers.

Changes:
- Use docker:24-dind as job container
- Remove installation steps (Docker pre-installed)
- Keep simple login, build, push workflow

Also added alternative solution file showing how to configure
runner with Docker CLI for better performance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:56:59 +01:00
Matt
9869355146 Install Docker CLI in workflow before use
Some checks failed
Build and Push Docker Image / build (push) Failing after 4s
Root cause: Gitea act_runner mounts Docker socket but doesn't
include Docker CLI by default to keep the image lightweight.

Solution: Install docker-ce-cli package before running any
docker commands. This allows the workflow to communicate with
the Docker daemon via the mounted socket.

Changes:
- Add step to install Docker CLI from official Docker repository
- Verify installation with docker version
- Continue with login, build, and push steps

Based on Zen expert analysis of the runner environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:55:21 +01:00
Matt
6d53650352 Switch to Docker-based workflow with CLI commands
Some checks failed
Build and Push Docker Image / build (push) Failing after 4s
Replace Kaniko approach with direct Docker CLI commands.
The Gitea runner mounts Docker socket, making Docker available
in ubuntu-latest environment.

Key changes:
- Remove container specification (Kaniko lacks shell utilities)
- Use docker login with password-stdin for authentication
- Build with docker build using multiple -t tags
- Push both latest and commit SHA tags
- Works with Docker-based Gitea runners

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:53:34 +01:00
Matt
8de8fc9b40 Remove --user root option from Kaniko container
Some checks failed
Build and Push Docker Image / build (push) Failing after 0s
The Kaniko executor image doesn't have traditional user management
and runs with appropriate permissions by default.

Fixes: unable to find user root: no matching entries in passwd file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:51:15 +01:00
Matt
82093a0cf6 Fix CI workflow to use Kaniko for containerized runner
Some checks failed
Build and Push Docker Image / build (push) Failing after 4s
Replace Docker-based build with Kaniko executor to support
Docker-based Gitea runners that don't have Docker daemon access.

Kaniko builds container images without requiring Docker,
making it ideal for containerized CI environments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:50:22 +01:00
Matt
1c9c570ece Add CI/CD pipeline with Gitea Actions and Portainer deployment
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
- Create Gitea Actions workflow for automated Docker builds on push to main
- Add docker-compose.portainer.yml for production Portainer deployment
- Create comprehensive DEPLOYMENT.md guide with step-by-step instructions
- Update CLAUDE.md with CI/CD pipeline documentation

Images are built and pushed to Gitea registry at:
code.puffinoffset.com/matt/puffin-app:latest
code.puffinoffset.com/matt/puffin-app:main-<sha>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:31:04 +01:00