Commit graph

187 commits

Author SHA1 Message Date
Andras Bacsai
236745ede1 chore: prepare for PR 2026-03-01 18:49:40 +01:00
Andras Bacsai
992b922df3 chore: prepare for PR 2026-02-25 11:50:57 +01:00
peaklabs-dev
efa7bddda6
fix(labels): make sure name is slugified 2026-02-04 18:02:18 +01:00
Murat Aslan
ef07c68588
fix: cast docker version to int for proper comparison (#7760) 2026-01-05 22:20:47 +01:00
Andras Bacsai
0f54c194d7 Add Garage as a one-click service
Adds support for deploying Garage (S3-compatible object storage) as a
one-click service in Coolify. Includes service template with TOML config,
automatic URL generation for S3, Web, and Admin endpoints with reverse
proxy configuration, and UI fields for credentials and access tokens.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 13:46:57 +01:00
Andras Bacsai
dd9ea00914 Fix PostgREST misclassification and empty Domains section
- Replace substring matching with exact base image name comparison in isDatabaseImage() to prevent false positives (postgres no longer matches postgrest)
- Add 'timescaledb' and 'timescaledb-ha' to DATABASE_DOCKER_IMAGES constants for proper namespace handling
- Add empty state messaging when no applications are defined in Docker Compose configuration
- Maintain backward compatibility with all existing database patterns

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 16:52:09 +01:00
Andras Bacsai
d59c75c2b2 Fix: Docker build args injection regex to support service names
The regex pattern in injectDockerComposeBuildArgs() was too restrictive
and failed to match `docker compose build servicename` commands. Changed
the lookahead from `(?=\s+(?:--|-)|\s+(?:&&|\|\||;|\|)|$)` to the
simpler `(?=\s|$)` to allow any content after the build command,
including service names with hyphens/underscores and flags.

Also improved the ApplicationDeploymentJob to use the new helper function
and added comprehensive test coverage for service-specific builds.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 13:16:05 +01:00
Andras Bacsai
f3abc4a29f refactor: fix variable scope in docker entrypoint parsing
Improve variable initialization consistency in convertDockerRunToCompose()
function to match established patterns used for --gpus and --hostname.

Changes:
- Add explicit $value = null initialization in --entrypoint block
- Simplify conditional check from isset($value) to $value check
- Maintain semantic equivalence with zero behavior changes

This refactoring eliminates potential undefined variable warnings and
improves code maintainability by following the defensive pattern used
elsewhere in the file.

Also fixes namespace for RestoreDatabase command from App\Console\Commands
to App\Console\Commands\Cloud to match file location and prevent class
redeclaration errors.

Tests: All 20 tests in DockerCustomCommandsTest pass (25 assertions)
2025-11-26 09:32:09 +01:00
Andras Bacsai
1d277f28dd
feat: custom docker entrypoint (#7097) 2025-11-26 09:31:02 +01:00
Andras Bacsai
7ceb124e9b feat: add validation for YAML parsing, integer parameters, and Docker Compose custom fields
This commit adds comprehensive validation improvements and DRY principles for handling Coolify's custom Docker Compose extensions.

## Changes

### 1. Created Reusable stripCoolifyCustomFields() Function
- Added shared helper in bootstrap/helpers/docker.php
- Removes all Coolify custom fields (exclude_from_hc, content, isDirectory, is_directory)
- Handles both long syntax (arrays) and short syntax (strings) for volumes
- Well-documented with comprehensive docblock
- Follows DRY principle for consistent field stripping

### 2. Fixed Docker Compose Modal Validation
- Updated validateComposeFile() to use stripCoolifyCustomFields()
- Now removes ALL custom fields before Docker validation (previously only removed content)
- Fixes validation errors when using templates with custom fields (e.g., traccar.yaml)
- Users can now validate compose files with Coolify extensions in UI

### 3. Enhanced YAML Validation in CalculatesExcludedStatus
- Added proper exception handling with ParseException vs generic Exception
- Added structure validation (checks if parsed result and services are arrays)
- Comprehensive logging with context (error message, line number, snippet)
- Maintains safe fallback behavior (returns empty collection on error)

### 4. Added Integer Validation to ContainerStatusAggregator
- Validates maxRestartCount parameter in both aggregateFromStrings() and aggregateFromContainers()
- Corrects negative values to 0 with warning log
- Logs warnings for suspiciously high values (> 1000)
- Prevents logic errors in crash loop detection

### 5. Comprehensive Unit Tests
- tests/Unit/StripCoolifyCustomFieldsTest.php (NEW) - 9 tests, 43 assertions
- tests/Unit/ContainerStatusAggregatorTest.php - Added 6 tests for integer validation
- tests/Unit/ExcludeFromHealthCheckTest.php - Added 4 tests for YAML validation
- All tests passing with proper Log facade mocking

### 6. Documentation
- Added comprehensive Docker Compose extensions documentation to .ai/core/deployment-architecture.md
- Documents all custom fields: exclude_from_hc, content, isDirectory/is_directory
- Includes examples, use cases, implementation details, and test references
- Updated .ai/README.md with navigation links to new documentation

## Benefits
- Better UX: Users can validate compose files with custom fields
- Better Debugging: Comprehensive logging for errors
- Better Code Quality: DRY principle with reusable validation
- Better Reliability: Prevents logic errors from invalid parameters
- Better Maintainability: Easy to add new custom fields in future

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 18:34:49 +01:00
Andras Bacsai
d753d49ce6 fix: improve -f flag detection to prevent false positives
- Refine regex pattern to prevent false positives with flags like -foo, -from, -feature
- Change from \S (any non-whitespace) to [.~/]|$ (path characters or end of word)
- Add comprehensive tests for false positive prevention (4 test cases)
- Add path normalization tests for baseDirectory edge cases (6 test cases)
- Add @example documentation to injectDockerComposeFlags function

Prevents incorrect detection of:
- -foo, -from, -feature, -fast as the -f flag
- Ensures -f flag is only detected when followed by path characters or end of word

All 45 tests passing with 135 assertions.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 13:49:46 +01:00
Andras Bacsai
f86ccfaa9a fix: auto-inject -f and --env-file flags into custom Docker Compose commands 2025-11-18 13:07:54 +01:00
Andras Bacsai
919fc184b7 fix(docker): improve pull request ID check in container status function 2025-11-09 20:35:03 +01:00
Andras Bacsai
67605d50fc fix(deployment): prevent base deployments from being killed when PRs close (#7113)
- Fix container filtering to properly distinguish base deployments (pullRequestId=0) from PR deployments
- Add deployment cancellation when PR closes via webhook to prevent race conditions
- Prevent CleanupHelperContainersJob from killing active deployment containers
- Enhance error messages with exit codes and actual errors instead of vague "Oops" messages
- Protect status transitions in finally blocks to ensure proper job failure handling
2025-11-09 14:41:35 +01:00
Andras Bacsai
1ab5dbca20 fix: preserve empty strings and remove empty sections in docker-compose
- Preserve empty string environment variables instead of converting to null
  Empty strings and null have different semantics in Docker Compose:
  * Empty string (VAR: ""): Variable is set to "" in container (e.g., HTTP_PROXY="" means "no proxy")
  * Null (VAR: null): Variable is unset/removed from container environment

- Remove empty top-level sections (volumes, configs, secrets) from generated compose files
  These sections now only appear when they contain actual content, following Docker Compose best practices

- Add safety check for missing volumes in validateComposeFile to prevent iteration errors

- Add comprehensive unit tests for both fixes

Fixes #7126
2025-11-06 12:30:03 +01:00
Aditya Tripathi
f5d549365c fix: handle escaped quotes in docker entrypoint parsing 2025-11-03 21:10:32 +00:00
Aditya Tripathi
f89b86491b feat: custom docker entrypoint 2025-11-03 13:44:06 +00:00
Andras Bacsai
70f152f0ba Changes auto-committed by Conductor 2025-10-16 08:51:15 +02:00
Andras Bacsai
ed07e662ea
Update bootstrap/helpers/docker.php
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-10-15 14:51:36 +02:00
Andras Bacsai
41afa9568d fix: handle null environment variable values in bash escaping
Previously, the bash escaping functions (`escapeBashEnvValue()` and `escapeBashDoubleQuoted()`) had strict string type hints that rejected null values, causing deployment failures when environment variables had null values.

Changes:
- Updated both functions to accept nullable strings (`?string $value`)
- Handle null/empty values by returning empty quoted strings (`''` for single quotes, `""` for double quotes)
- Added 3 new tests to cover null and empty value handling
- All 29 tests pass

This fix ensures deployments work correctly even when environment variables have null values, while maintaining the existing behavior for all other cases.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 13:35:58 +02:00
Andras Bacsai
acf2d5f89b refactor(deployment): update environment variable handling for Docker builds
- Changed the .env file reference to use a build-time .env file located in /artifacts, preventing it from being included in Docker images.
- Introduced a new method to wrap Docker build commands with environment variable exports, enhancing the handling of build-time variables.
- Updated logging messages for clarity regarding the creation and usage of the build-time .env file.
2025-10-06 10:31:58 +02:00
Andras Bacsai
aadde3a83e feat(deployments): enhance Docker build argument handling for multiline variables
- Introduced new helper functions to generate Docker build arguments and environment flags, accommodating multiline variables with proper escaping.
- Updated the ApplicationDeploymentJob to utilize these new functions, improving the handling of environment variables during deployment.
- Added comprehensive tests to ensure correct behavior for multiline variables and special characters.
2025-10-02 13:54:36 +02:00
Andras Bacsai
c1799bdae6 fix(docker): redirect stderr to stdout for container log retrieval to capture error messages 2025-09-18 12:51:03 +02:00
Andras Bacsai
133e72336a Revert "refactor(file-transfer): replace base64 encoding with direct file transfer method in various components for improved clarity and efficiency"
This reverts commit feacedbb04.
2025-09-15 17:56:48 +02:00
Andras Bacsai
feacedbb04 refactor(file-transfer): replace base64 encoding with direct file transfer method in various components for improved clarity and efficiency 2025-09-09 11:10:38 +02:00
Andras Bacsai
2e85ce0e0e refactor(urls): replace generateFqdn with generateUrl for consistent URL generation across applications 2025-08-28 09:49:58 +02:00
Andras Bacsai
21fc1ba254 fix(docker): update parser version in FQDN generation for service-specific URLs 2025-08-27 17:02:38 +02:00
Andras Bacsai
e8892b3d29 feat(core): finally fqdn is fqdn and url is url. haha 2025-08-12 10:06:19 +02:00
Yanluis Fermin
e572017d27
fix(api): duplicated logs in application endpoint (#6292) 2025-08-11 14:03:46 +02:00
Andras Bacsai
b7602e30b3 fix(docker): conditionally enable gzip compression in Traefik labels based on configuration 2025-06-25 13:11:44 +02:00
Andras Bacsai
842f22340e refactor(database-detection): enhance isDatabaseImage function to utilize service configuration for improved detection accuracy 2025-06-04 11:44:37 +02:00
Andras Bacsai
698b090b4d fix(docker): ensure correct parsing of environment variables by limiting explode to 2 parts 2025-05-22 14:27:55 +02:00
Andras Bacsai
08d2ad83ee fix(docker): enhance hostname and GPU option validation in Docker run to compose conversion 2025-04-23 13:34:27 +02:00
Andras Bacsai
04e1d5c75d fix(docker): ensure password hashing only occurs when HTTP Basic Authentication is enabled 2025-04-23 13:30:27 +02:00
Andras Bacsai
78ef80f800 refactor 2025-04-23 13:22:01 +02:00
Andras Bacsai
e4648bcf9c feat(docker): add HTTP Basic Authentication support and enhance hostname parsing in Docker run conversion 2025-04-23 11:57:26 +02:00
Andras Bacsai
8520beff51 refactor(docker): remove debug statement and enhance hostname handling in Docker run conversion 2025-04-23 11:21:37 +02:00
Andras Bacsai
bce8bb1f2d
Merge branch 'next' into add-hostname 2025-04-22 22:03:45 +02:00
Andras Bacsai
9e608f7ba5 refactor(http-basic-auth): rename 'http_basic_auth_enable' to 'http_basic_auth_enabled' across application files for consistency 2025-04-22 21:30:27 +02:00
Andras Bacsai
7e0373e439
Merge branch 'next' into feat/add-http-basic-auth 2025-04-22 21:18:43 +02:00
Andras Bacsai
6d12e7edc7 refactor(database): simplify database type checks in ServiceDatabase and enhance image validation in Docker helper 2025-04-21 09:57:27 +02:00
Christopher Kaster
2634f516d5
feat: Add HTTP Basic Authentication 2025-04-17 14:14:32 +02:00
sebi
4f5df53f1f add hostname 2025-04-04 18:39:52 +01:00
Andras Bacsai
98add9fd0f refactor(docker): parse and sanitize YAML compose file before encoding 2025-03-28 21:11:28 +01:00
Andras Bacsai
a402c28606 fix(revert): label parsing 2025-02-28 20:25:19 +01:00
Andras Bacsai
1c21652d5d fix(core): Improve label generation and merging for applications and services 2025-02-28 12:44:20 +01:00
Andras Bacsai
e1c5ace342 fix(docker): Improve Docker compose file validation process
- Increase UUID length for better uniqueness
- Add server existence check before validation
- Implement cleanup of temporary compose file in finally block
2025-02-27 12:17:12 +01:00
Andras Bacsai
27e4882d57 feat(core): You can validate compose files with docker compose config
fix(core): labels are now accepted with both compose styles
refactor: remove lots of ray's
2025-02-27 11:29:04 +01:00
Vann
7b60d76b77 feat: remove ansi color from log 2025-02-02 10:01:01 +00:00
Vann
e7988fc295 feat: container logs 2025-02-01 17:21:38 +00:00