Commit Graph

316 Commits

Author SHA1 Message Date
f9b8cf9f33 feat: add API Gateway, RapidMail and Shopify integrations, update WireGuard configs, add Redis override and architecture docs 2025-11-04 23:08:17 +01:00
5d6edea3bb feat(deployment): migrate to external Redis stack
Architecture Changes:
- Remove embedded Redis service from production configuration
- Remove port 80/443 direct bindings (Traefik handles routing)
- Update queue-worker and scheduler dependencies (Redis now external)
- Completes Redis stack migration following PostgreSQL pattern
- Resolves port conflict with Traefik reverse proxy

Related Files:
- deployment/stacks/redis/docker-compose.yml (Redis stack - already deployed)
- docker-compose.redis-override.yml (application integration - already created)

Migration Benefits:
- Architectural consistency with PostgreSQL stack pattern
- Better separation of concerns (infrastructure vs application)
- Independent Redis lifecycle management
- Shared Redis instance via app-internal network
- Eliminated port 80 binding conflict

Deployment Command:
docker compose -f docker-compose.base.yml -f docker-compose.production.yml \
  -f docker-compose.postgres-override.yml -f docker-compose.redis-override.yml up -d
2025-11-04 22:31:37 +01:00
7246e89448 fix(deployment): add CHOWN and DAC_OVERRIDE capabilities to Redis for AOF persistence
The Redis container was failing with 'Permission denied' when trying to create
the appendonlydir for AOF (Append-Only File) persistence. The error occurred because:

1. Redis runs as root to read Docker Secrets from /run/secrets/redis_password
2. The /data volume is owned by UID 999 (default redis user)
3. cap_drop: ALL removed the CHOWN capability needed to create subdirectories
4. AOF persistence requires creating appendonlydir in /data with proper ownership

Solution:
- Added CHOWN capability: Allows Redis to create directories with correct ownership
- Added DAC_OVERRIDE capability: Allows writing to volume owned by different user
- Maintains all other security restrictions (no-new-privileges, minimal capabilities)

This fixes the continuous restart loop that persisted through commits:
- 5f7ebd9: Fixed healthcheck variable syntax
- 700fe81: Fixed entrypoint script variables
- bfe6a96: Changed healthcheck to read secret directly

The real issue was not the healthcheck but the permission error that prevented
Redis from starting in the first place.

Refs: Redis container logs showed:
'Can't open or create append-only dir appendonlydir: Permission denied'
2025-11-04 21:29:32 +01:00
bfe6a966b5 fix(deployment): Redis health check reads password directly from Docker Secret
The health check now reads the password directly from /run/secrets/redis_password
instead of relying on an environment variable, which is not available in the
health check context.

This resolves the 'container application-redis-1 is unhealthy' error.
2025-11-04 21:16:25 +01:00
3ed2685e74 feat: add comprehensive framework features and deployment improvements
Major additions:
- Storage abstraction layer with filesystem and in-memory implementations
- Gitea API integration with MCP tools for repository management
- Console dialog mode with interactive command execution
- WireGuard VPN DNS fix implementation and documentation
- HTTP client streaming response support
- Router generic result type
- Parameter type validator for framework core

Framework enhancements:
- Console command registry improvements
- Console dialog components
- Method signature analyzer updates
- Route mapper refinements
- MCP server and tool mapper updates
- Queue job chain and dependency commands
- Discovery tokenizer improvements

Infrastructure:
- Deployment architecture documentation
- Ansible playbook updates for WireGuard client regeneration
- Production environment configuration updates
- Docker Compose local configuration updates
- Remove obsolete docker-compose.yml (replaced by environment-specific configs)

Documentation:
- PERMISSIONS.md for access control guidelines
- WireGuard DNS fix implementation details
- Console dialog mode usage guide
- Deployment architecture overview

Testing:
- Multi-purpose attribute tests
- Gitea Actions integration tests (typed and untyped)
2025-11-04 20:39:48 +01:00
700fe8118b fix(deployment): complete Redis health check fix - update entrypoint script variable syntax
Previous fix (5f7ebd9) only updated health check line but missed entrypoint script.
The entrypoint script was still using $$REDIS_PASSWORD (Docker Compose escaping)
instead of $REDIS_PASSWORD (shell variable syntax).

Changes:
- Line 180: export REDIS_PASSWORD=$(cat ...) - now uses single $
- Line 182: if [ -n "$REDIS_PASSWORD" ] - now uses single $
- Line 190: --requirepass "$REDIS_PASSWORD" - now uses single $

Technical explanation:
The command: block is a multi-line shell script passed to /bin/sh -c.
Within this shell script context, we use normal shell variable syntax with
single $ for variable references. The export statement makes REDIS_PASSWORD
available to both the Redis process and the health check command.

This completes the fix for: "container application-redis-1 is unhealthy"

Related: 5f7ebd9 (health check fix), b1e3a00 (fallback strategy)
2025-11-04 19:24:06 +01:00
5f7ebd9133 fix(deployment): correct Redis health check variable syntax for environment variable access
- Changed health check from $$REDIS_PASSWORD to $REDIS_PASSWORD
- Double dollar sign is Docker Compose variable escaping (wrong context)
- Single dollar sign correctly references environment variable exported by entrypoint
- Health check runs in container shell where REDIS_PASSWORD is available
- Fixes 'container application-redis-1 is unhealthy' deployment failure
2025-11-04 18:33:03 +01:00
b8cfabeed0 Trigger workflow to build missing Docker image for deployment
Added comment to force Gitea workflow execution and build Docker image
for deployment fix #12.
2025-11-04 18:16:58 +01:00
5633959b9d fix(deployment): use environment variable for Redis health check authentication
Changes:
- Export REDIS_PASSWORD from Docker Secret in entrypoint script
- Health check now uses exported environment variable instead of reading Secret file
- Increased start_period to 30s to allow more time for initialization

Why this works:
- Environment variables are accessible to both main process and health checks
- Docker Secret file reading in health check context was unreliable
- Export makes password available in same shell session for health check

Security:
- Password still sourced from Docker Secret (encrypted at rest)
- Only exported within container environment (not exposed externally)
- Redis still requires password authentication (--requirepass)

Deployment fix #11 (continued): Redis container health check
2025-11-04 17:40:48 +01:00
b1e3a0025a fix(deployment): improve Redis health check with fallback strategy
Changed health check to try without password first, then with Docker Secret.
This handles both scenarios where password might not be immediately available
or where the Secret read might fail in health check context.

Changes:
- Use CMD-SHELL instead of CMD for shell expansion support
- Try 'redis-cli ping' first (no auth)
- Fallback to authenticated ping if first attempt fails
- Properly quote password from Docker Secret

This is the eleventh cumulative fix for production deployment pipeline.

Related: commit 477fe67 (initial Redis health check fix)
2025-11-04 17:28:54 +01:00
5b958dc6b1 fix(deployment): remove db service from base config - use external PostgreSQL stack for all environments
User specified that all environments (local, staging, production) should
use external PostgreSQL stacks consistently instead of embedded database.

Changes:
- Removed db service definition from base config (lines 87-114)
- Removed db dependency from queue-worker service
- Updated php-test DB_HOST to use external 'postgres' service

This eliminates the need for production overrides and creates uniform
architecture across all environments. The application-db-1 container
will no longer be started, fixing deployment failure.

This is the tenth cumulative fix for production deployment pipeline.

Related commits:
- f97863a: Add image references to production config
- 5b5fdee: Fix registry upload with sequential push
- a1b9a53: Remove CI test file
- 0b54086: Fix Node.js cache dependency
- 6263d7a: Trigger CI workflow verification
- 08f6f64: Stable IMAGE_TAG
- 2e539ed: Add build: null overrides
- 6e1faab: Deploy docker-compose via scp
- c1d6a71: Fix scp working directory
- a4ca6e9: Trigger pipeline
- 0c0c3ba: Fix .env mount conflict
- 41882da: Fix storage/var volume mounts
- 477fe67: Fix Redis health check
2025-11-04 17:19:20 +01:00
477fe6767e fix(deployment): correct Redis health check command and add authentication
Previous health check used incorrect command: redis-cli --raw incr ping
This increments a counter instead of checking Redis health.

Changed to proper health check:
- Use standard redis-cli ping command
- Authenticate with password from Docker Secret
- Verify PONG response with grep

This is the ninth cumulative fix for production deployment pipeline.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 17:01:47 +01:00
41882dafe6 fix(deployment): change application mount to read-write, remove storage/var volume overlays
Docker named volumes cannot create mount points inside read-only directories.
Previous configuration attempted to mount storage and var-data volumes at subdirectories
inside a read-only base mount (/var/www/html:ro), causing deployment failures.

Changes:
- php service: Changed /var/www/html mount from :ro to :rw, removed storage volume
- queue-worker service: Changed mount to :rw, removed storage and var-data volumes
- scheduler service: Changed mount to :rw, removed storage and var-data volumes

Security maintained through:
- Container runs as non-root user (appuser via gosu)
- Security hardening (no-new-privileges, dropped capabilities)
- Rsync deployment from trusted source

This is the eighth cumulative fix for production deployment pipeline.
2025-11-04 16:43:46 +01:00
0c0c3ba845 fix(deployment): remove conflicting .env file mounts
Remove separate .env file mounts from php, queue-worker, and scheduler
services to fix read-only filesystem mount conflict.

The .env file is already included in the rsync deployment at
/home/deploy/michaelschiemer/current/.env and is accessible through
the main application code mount. Separate file mounts are redundant
and cause Docker mount conflicts because they attempt to create mount
points inside read-only parent directories.

Error fixed:
- error mounting '/var/www/html/.env': read-only file system

Services fixed:
- php: removed .env mount (line 154)
- queue-worker: removed .env mount (line 254)
- scheduler: removed .env mount (line 327)
2025-11-04 16:24:06 +01:00
a4ca6e9e16 chore: trigger pipeline for scp working directory fix
Update comment to trigger CI/CD workflow with cd /workspace/repo fix
(commit c1d6a71).

This deployment will:
1. cd to /workspace/repo before scp
2. Transfer docker-compose files successfully
3. Deploy all six fixes to production
2025-11-04 16:10:39 +01:00
c1d6a71494 fix(deployment): cd to /workspace/repo before scp
The 'Deploy to Production Server' step is separate from the clone step and
doesn't inherit the working directory. The scp command was running from the
default directory where docker-compose files don't exist.

Adding 'cd /workspace/repo' before scp to access the cloned repository files.

This fixes the error:
docker-compose.base.yml: No such file or directory
docker-compose.production.yml: No such file or directory
2025-11-04 16:07:05 +01:00
870db892e7 chore: trigger pipeline for docker-compose scp deployment
Update comment to trigger CI/CD workflow with docker-compose file deployment
via scp (commit 6e1faab).

This deployment will:
1. Build and push image with stable git-SHA tag
2. Transfer docker-compose.base.yml and docker-compose.production.yml via scp
3. Pull new image on production server
4. Restart services with updated configuration including build: null overrides

All five deployment fixes are now integrated:
- Sequential push (0b342c6)
- Stable IMAGE_TAG (08f6f64)
- build: null overrides (2e539ed)
- scp docker-compose deployment (6e1faab)
- Source file trigger (this commit)
2025-11-04 16:01:49 +01:00
6e1faabdc1 fix(deployment): deploy docker-compose files via scp before SSH execution
The previous 'always sync' approach failed because it tried to copy files
from /workspace/repo/ which doesn't exist on the production server.

The SSH heredoc (<<EOF) executes commands ON the production server, not in
the Gitea Actions workspace. File paths inside heredoc are relative to the
production server's filesystem.

This commit adds an scp step BEFORE the SSH heredoc to transfer
docker-compose.base.yml and docker-compose.production.yml from the Actions
workspace to the production server.

This ensures the build: null overrides (commit 2e539ed) reach production
and services can restart without build context errors.

Changes:
- Added scp command to deploy docker-compose files before SSH deployment
- Changed file sync check from 'cp' to file existence validation
- Updated comments to clarify rsync-based deployment architecture

Related commits:
- 0b342c6: Sequential push strategy
- 08f6f64: Stable git-SHA IMAGE_TAG
- 2e539ed: build: null overrides
- 0db73df: Always-sync docker-compose (incorrect implementation)
- 3091205: Trigger pipeline with source file change
2025-11-04 16:01:11 +01:00
3091205f20 chore: trigger deployment with all fixes
Trigger pipeline to deploy all four cumulative fixes:
1. Sequential push strategy (prevents 499 registry errors)
2. Stable git-SHA IMAGE_TAG format (fixes manifest not found)
3. build: null overrides (prevents build context errors)
4. Always-sync docker-compose files (ensures config updates deploy)

This source file change triggers the pipeline execution since
workflow file changes are filtered by IGNORE_PATTERN.
2025-11-04 15:51:33 +01:00
0db73df2df fix(deployment): always sync docker-compose files from repo
The deployment script was only copying docker-compose files when missing,
preventing configuration updates (like build: null overrides) from being deployed.

Changed from conditional copy to always sync latest files from repository,
ensuring all configuration changes are properly deployed to production.
2025-11-04 15:43:02 +01:00
8b1cde874e test: trigger build with build override fix 2025-11-04 15:33:06 +01:00
2e539ed330 fix(deployment): explicitly override build sections with null in production
Added 'build: null' to web, php, and queue-worker services in docker-compose.production.yml
to explicitly remove build sections inherited from base config.

This fixes 'lstat /home/deploy/deployment/stacks/application/docker/php: no such file or directory'
error during deployment, as production servers only have docker-compose files, not build context.

Registry-based deployment should pull pre-built images, not attempt to build on production server.
2025-11-04 15:32:36 +01:00
3644621b00 test: trigger build with updated IMAGE_TAG fix 2025-11-04 15:22:39 +01:00
08f6f64d72 fix(ci): use stable git-SHA tag for deployment instead of timestamp
Changed IMAGE_TAG output from timestamp-based format to stable git-SHA format to ensure
deployment can reliably pull the image that was actually pushed to the registry.

Before: IMAGE_TAG="6c7040e-1762265632" (changes with time)
After: IMAGE_TAG="git-6c7040e" (stable, matches pushed tag)

This fixes deployment manifest not found errors.
2025-11-04 15:20:34 +01:00
6c7040e049 test: trigger production deployment pipeline 2025-11-04 15:10:07 +01:00
0b342c68bb fix(ci): change docker build to load then push tags sequentially
Docker registry was getting overwhelmed with concurrent pushes of
multiple tags and cache layers, resulting in 499 status code
(Client Closed Request).

Changes:
- Build with --load instead of --push to save image locally first
- Push each tag sequentially (latest, timestamp, git-sha) instead of all at once
- Reduce cache targets from 2 to 1 (keep only buildcache)
- Add progress logging for each push operation

This approach:
1. Reduces concurrent write pressure on registry
2. Allows better error handling per tag
3. Provides clearer progress feedback
4. Prevents registry timeouts from concurrent uploads

Related to: Status 499 error during docker push
2025-11-04 15:04:57 +01:00
f97863af40 fix(deployment): add image references to docker-compose.production.yml
Production deployment was failing because docker-compose.production.yml
had build: sections but no image: references. This caused Docker Compose
to attempt building on the server, which failed because the docker/
directory doesn't exist in the deployment location.

Changes:
- Add image: git.michaelschiemer.de:5000/framework:latest to web, php, and queue-worker services
- Removed build: section from php service (no longer needed)
- Remove test comment from ShowHome.php

The deployment script's sed command (line 1259-1260 in build-image.yml)
now successfully finds and updates the image: tags with the correct
version from the registry.

Related to: Production deployment error "docker/php: no such file or directory"
2025-11-04 14:52:45 +01:00
5b5fdeeba7 test: trigger production deployment pipeline 2025-11-04 14:42:24 +01:00
a1b9a53b32 chore: remove temporary CI test file 2025-11-04 14:28:22 +01:00
0b54086851 fix(ci): remove actions/cache step that requires Node.js
- Gitea runner doesn't have Node.js installed
- actions/cache@v4 requires Node.js runtime
- vendor/ caching handled by runner workspace persistence
2025-11-04 14:28:00 +01:00
6263d7ab50 test(ci): trigger CI workflow verification 2025-11-04 14:18:36 +01:00
bfce93ce77 refactor(console, id, config): Dialog mode in Console, consolidated id modul, added config support for ini directives 2025-11-04 13:44:27 +01:00
980714f656 refactor(logging): remove redundant log record creation in DefaultLogger handlers loop 2025-11-04 11:10:51 +01:00
02e4dc9338 feat(local-secrets): introduce unified local secrets management and documentation
- Add example secret files for `app_key`, `db_user_password`, and `redis_password`.
- Introduce `local.vault.yml.example` for Ansible Vault encryption of local secrets.
- Create migration and setup scripts for transitioning from `.env.local` to secrets files.
- Update `docker-compose.local.yml` to adopt Docker Secrets and `_FILE` pattern for local configurations.
- Add deployment playbooks and enhanced logging configurations for local development.
2025-11-04 11:06:21 +01:00
12afbe874d refactor(container): simplify Redis pool initialization flow
- Remove redundant `$container` parameter in `RedisPoolInitializer` instantiation.
- Streamline container interactions for improved clarity and maintainability.
2025-11-04 02:43:45 +01:00
315b54a209 refactor(container): simplify Redis pool initialization flow
- Remove redundant `$container` parameter in `RedisPoolInitializer` instantiation.
- Streamline container interactions for improved clarity and maintainability.
2025-11-04 02:10:15 +01:00
e68c25f004 refactor(redis): refine connection handling and pool singleton initialization
- Mark `RedisConnection::$connected` as read-only with `private(set)`.
- Simplify authentication and database selection logic in `RedisConnection`.
- Comment out DI container singleton registration in `RedisPoolInitializer`.
- Annotate `RedisConnectionPool` with `#[Singleton]` attribute for improved clarity.
2025-11-04 02:00:47 +01:00
e8f6b239c6 refactor(redis, discovery, cache): enhance validation, error handling, and class filtering
- Remove redundant fallback for `RedisConfig` key prefix to enforce explicit configuration.
- Refine `ClassExtractor` with class name validation to exclude invalid identifiers and handle creation errors.
- Improve `AttributeCache` by validating class existence before reflection, preventing unnecessary exceptions and caching empty results on failure.
2025-11-04 01:44:26 +01:00
3606a13ab9 refactor(redis, discovery, cache): streamline configuration defaults, logging, and error handling
- Remove default values for `RedisConfig` constructor to enforce explicit configuration.
- Enhance `FileStreamProcessor` logging by adding `LogContext` with exception details.
- Replace `humanReadable` method call with `toHumanReadable` in `DiscoveryCompletedEvent`.
- Remove redundant error trace logging in `CacheInitializer` for cleaner fallback handling.
2025-11-04 01:26:27 +01:00
f83b61d80f refactor(discovery): improve dependency analysis with enhanced namespace resolution and error handling
- Introduce `normalizeTypeName` to validate and normalize type names during dependency analysis.
- Add `safeCreateClassName` to handle `ClassName` creation errors gracefully.
- Enhance constructor, method, property, and return type dependency edge creation with context-aware namespace resolution.
- Improve logging to capture failure details and provide debugging insights.
2025-11-04 01:08:06 +01:00
1a31ce66c9 refactor(discovery): clarify file processing error message in FileProcessor logging 2025-11-04 01:05:03 +01:00
3085739e34 feat(filesystem): introduce FileOwnership and ProcessUser value objects
- Add `FileOwnership` to encapsulate file owner and group information.
- Add `ProcessUser` to represent and manage system process user details.
- Enhance ownership matching and debugging with structured data objects.
- Include new documentation on file ownership handling and permission improvements.
- Prepare infrastructure for enriched error handling in filesystem operations.
2025-11-04 00:56:49 +01:00
30d15d1b20 refactor(discovery): enhance exception handling and logging context in FileProcessor
- Add `DiscoveryErrorCode` and `FileSystemErrorCode` to improve error classification in `DiscoveryException`.
- Integrate `LogContext` into `FileProcessor` warnings for enriched logging details.
- Simplify `Environment` variable handling by removing redundant condition checks.
2025-11-04 00:22:10 +01:00
56f09b5001 docs(cache): add comprehensive cache configuration and permission handling guides
- Introduce `cache-configuration.md` for detailed instructions on cache setup, permission troubleshooting, and best practices.
- Add `cache-permissions-quick-fix.md` for concise resolutions to common permission errors.
- Include a detailed `FILECACHE_PERMISSION_FIX_PLAN.md` outlining solutions for permission-related issues.
- Enhance `docker-entrypoint.sh` with permission fixes for multi-user caches.
- Update `Makefile` with cache clear commands for local and staging environments.
- Improve `FileCache` for graceful degradation on permission errors, ensuring reliability under multi-user scenarios.
2025-11-03 23:54:27 +01:00
a1242f776e refactor(config): add EnumResolver for cache-backed enum resolution and extend DockerSecretsResolver with caching
- Introduce `EnumResolver` to centralize and cache enum value conversions.
- Enhance `DockerSecretsResolver` with result caching to avoid redundant file reads and improve performance.
- Update `Environment` to integrate `EnumResolver` for enriched enum resolution support and improved maintainability.
- Adjust unit tests to validate caching mechanisms and error handling improvements.
2025-11-03 23:47:08 +01:00
2a0c797051 refactor(cache): improve file handling and introduce robust locking mechanisms
- Refactor `FileCache` methods to enhance file operation consistency and error handling.
- Integrate `LockableStorage` for improved locking with fallback to manual lock implementations.
- Replace `glob` usage with `FileSystem` module for directory operations, improving maintainability and testability.
- Optimize cache file listing, filtering, and expiration handling for better performance and reliability.
- Streamline directory and file deletion logic with additional error resilience.
2025-11-03 23:30:07 +01:00
a071bea39e refactor(view): replace DefaultContainer with Container in TemplateProcessorInitializer
- Simplify constructor dependency by substituting `DefaultContainer` with `Container`.
2025-11-03 22:56:49 +01:00
1af63ed7ec refactor(view): simplify dependency injection for template initializers
- Replace `DefaultContainer` lookups with direct constructor injection in `TemplateProcessorInitializer` and `TemplateRendererInitializer`.
- Streamline method logic by removing redundant operations and ensuring dependencies are passed explicitly.
- Enhance readability and maintainability by reducing unnecessary indirections.
2025-11-03 22:48:27 +01:00
84a5a3fa21 chore(ci): update build workflow for targeted path triggers and concurrency management
- Refine branch and path filters for efficient CI triggers.
- Add concurrency control to avoid overlapping builds.
- Improve runtime base build logic with conditional evaluation and skipping.
- Enhance image info generation with fallback handling and deployment readiness checks.
2025-11-03 22:41:06 +01:00
a93a086ee4 refactor(di): add analysis components for dependency parsing and resolution
- Introduce `CodeParser` to extract dependencies from `container->get()` calls and `return new` statements.
- Add `DependencyPathAnalyzer` for recursive analysis of dependency paths with cycle detection.
- Implement `InitializerFinder` to locate initializers based on naming conventions.
- Include `InterfaceResolver` to determine interface implementations using introspection and initializers.
- Add `NamespaceResolver` for resolving class names from use statements and namespaces.
- Introduce `ReturnTypeAnalyzer` for method and closure return type analysis.
2025-11-03 22:38:06 +01:00