75 Commits
Author SHA1 Message Date
Andras Bacsai 116806df1b fix(compose): allow content files outside the resource directory again
Since aabd12737 a Compose bind volume with a content block had to stay
inside the resource directory. Services and Compose applications saved
in v4.3.23 with other paths, and Git Compose files with them, no longer
started or deployed.

Only admins and owners can edit Compose files, and they can already
write any host file with a plain bind mount, so the rule added no
security.

- Write content files to their host path again, as in v4.3.23
- Keep shell escaping and the safe-character checks on volume sources,
  so injection attempts are still rejected
2026-10-06 11:03:39 +02:00
Andras Bacsai a599c9e8b7 fix(server): keep data directory commands working for non-root SSH users
A non-root SSH user cannot open redirects, expand globs, or cd into
/data/coolify (9999:root 0700). Several remote commands relied on that
and failed on non-root servers.

- Write README files with `tee` instead of shell redirects in database
  starts and application deployments
- Clear Postgres init scripts with `find` instead of a glob
- Split the proxy config backfill if/else so each branch gets sudo
- Start the log drain with `docker compose -f` instead of `cd`
- Wrap the preserved-repository compose start in `sh -c` for non-root
- Stage clone archives outside /data/coolify via StagesCloneArchives
- Extend the sudo parser and add non-root command tests
2026-09-29 20:46:54 +02:00
Andras BacsaiandClaude Opus 5.5 fe6854c73e fix(storage): write content files before compose up and never drop their content
- Compose content files are written by a queued job. Deployments and
  service starts now check all content files with one command before
  docker compose up: a missing file or an empty directory (left by
  Docker) is written; an existing file is kept; a directory with files
  is kept with a visible warning.
- The server file sync that runs after every parse marked a file
  storage as a directory and deleted its configured content when a
  directory was at its path. A storage with content now keeps its
  content; an empty directory is replaced with the file.
- Saving a storage no longer fails for an existing file, replaces an
  empty directory, and no longer deletes a directory with files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 16:26:56 +02:00
Andras BacsaiandClaude Opus 5.5 aabd127374 fix(compose): keep content files inside the resource directory
- A Compose bind volume with a Coolify `content:` block could make
  Coolify write any host file (for example /root/.ssh/authorized_keys)
  when the file was loaded. Content sources must now be inside the
  resource directory (./ paths); other sources get a clear validation
  error for services and applications (UI, API, load, deployment),
  and every content write is confined again on the server. Bind
  mounts without content are unchanged. All 94 template content
  volumes use ./ paths and still work.
- Quote container names in scheduled tasks and in the stop actions for
  applications, previews, and services.
- Fix a development-only crash when a preview with a bind mount was
  parsed (the preview suffix returned a plain string).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 14:37:21 +02:00
Andras Bacsai 0935bf141e Improve volume path handling (#11993) 2026-09-24 23:22:35 +02:00
Andras Bacsai 7b7d5a0aad fix(services): add CDN and default logo fallbacks 2026-08-27 13:45:26 +02:00
Andras Bacsai 7c69b32c58 fix(services): handle empty compose environment sections (#11407) 2026-08-19 16:46:57 +02:00
Andras Bacsai 18c4663e0f Merge remote-tracking branch 'origin/next' into pr-10960-compose-settings-memory-crash 2026-08-13 11:31:50 +02:00
Andras Bacsai 0b843bb07c fix(compose): normalize service-name keys for domains and env vars (#11040) 2026-08-03 23:08:56 +02:00
Andras Bacsai 60129c2c47 fix: measure log size before ANSI strip; harden tasks and volumes
Truncate GetLogs against raw byte length, then strip ANSI colors.
Run scheduled-task docker exec with explicit sudo docker and no_sudo
to avoid double sudo rewriting on non-root servers. Mark git-based
file volumes as files before refreshing content from the server.
2026-07-16 16:02:51 +02:00
Andras Bacsai 14ecadc0de fix(services): avoid reading bind-mount files when syncing volumes
Stop catting remote file contents into memory for non-git bind mounts in
getFilesystemVolumesFromServer; git-based volumes still load via
loadStorageOnServer().
2026-07-16 14:24:12 +02:00
Andras Bacsai a362282976 chore: prepare for PR 2026-03-10 17:37:13 +01:00
Andras Bacsai 059164224c fix(bootstrap): add bounds check to extractBalancedBraceContent
Return null when startPos exceeds string length to prevent out-of-bounds
access. Add comprehensive test coverage for environment variable parsing
edge cases.
2026-03-02 12:24:40 +01:00
Andras BacsaiandClaude 208f0eac99 feat: add comprehensive environment variable parsing with nested resolution and hardcoded variable detection
This commit introduces advanced environment variable handling capabilities including:
- Nested environment variable resolution with circular dependency detection
- Extraction of hardcoded environment variables from docker-compose.yml
- New ShowHardcoded Livewire component for displaying detected variables
- Enhanced UI for better environment variable management

The changes improve the user experience by automatically detecting and displaying
environment variables that are hardcoded in docker-compose files, allowing users
to override them if needed. The nested variable resolution ensures complex variable
dependencies are properly handled.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-27 15:24:53 +01:00
Andras BacsaiandClaude 8c40cc607a Fix: Fragile service name parsing in applyServiceApplicationPrerequisites
Changed from `->before('-')` to `->beforeLast('-')` to correctly parse service
names with hyphens. This fixes prerequisite application for ~230+ services
containing hyphens in their template names (e.g., docker-registry,
elasticsearch-with-kibana).

Added comprehensive test coverage for hyphenated service names and fixed
existing tests to use realistic CUID2 UUID format. All unit tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:42:04 +01:00
Andras BacsaiandClaude 4706bc23aa Refactor: Centralize service application prerequisites
Refactors the Appwrite and Beszel service-specific application settings
to use a centralized constant-based approach, following the same pattern
as NEEDS_TO_CONNECT_TO_PREDEFINED_NETWORK.

Changes:
- Added NEEDS_TO_DISABLE_GZIP constant for services requiring gzip disabled
- Added NEEDS_TO_DISABLE_STRIPPREFIX constant for services requiring stripprefix disabled
- Created applyServiceApplicationPrerequisites() helper function in bootstrap/helpers/services.php
- Updated all service creation flows to use the centralized helper:
  * app/Livewire/Project/Resource/Create.php (web handler)
  * app/Http/Controllers/Api/ServicesController.php (API handler - BUG FIX)
  * app/Livewire/Project/New/DockerCompose.php (custom compose handler)
  * app/Http/Controllers/Api/ApplicationsController.php (API custom compose handler)
- Added comprehensive unit tests for the new helper function

Benefits:
- Single source of truth for service prerequisites
- DRY - eliminates code duplication between web and API handlers
- Fixes bug where API-created services didn't get prerequisites applied
- Easy to extend for future services (just edit the constant)
- More maintainable and testable

Related commits: 3a94f1ea1 (Beszel), 02b18c86e (Appwrite)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 16:47:09 +01:00
Andras BacsaiandClaude a5ce1db871 fix: handle map-style environment variables in updateCompose
The updateCompose() function now correctly detects SERVICE_URL_* and
SERVICE_FQDN_* variables regardless of whether they are defined in
YAML list-style or map-style format.

Previously, the code only worked with list-style environment definitions:
```yaml
environment:
  - SERVICE_URL_APP_3000
```

Now it also handles map-style definitions:
```yaml
environment:
  SERVICE_URL_TRIGGER_3000: ""
  SERVICE_FQDN_DB: localhost
```

The fix distinguishes between the two formats by checking if the array
key is numeric (list-style) or a string (map-style), then extracts the
variable name from the appropriate location.

Added 5 comprehensive unit tests covering:
- Map-style environment format detection
- Multiple map-style variables
- References vs declarations in map-style
- Abbreviated service names with map-style
- Verification of dual-format handling

This fixes variable detection for service templates like trigger.yaml,
langfuse.yaml, and paymenter.yaml that use map-style format.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 11:21:49 +01:00
Andras BacsaiandClaude 56f32d0f87 fix: properly handle SERVICE_URL and SERVICE_FQDN for abbreviated service names (#7243)
Parse template variables directly instead of generating from container names. Always create both SERVICE_URL and SERVICE_FQDN pairs together. Properly separate scheme handling (URL has scheme, FQDN doesn't). Add comprehensive test coverage.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 11:21:49 +01:00
Andras Bacsai 7fc4a2f7f6 feat: implement service environment variable parsing and add unit tests for port detection logic 2025-11-11 11:19:33 +01: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 5b3b4bbc43 refactor(environment): remove 'is_build_time' attribute from environment variable handling across the application to simplify configuration 2025-09-11 16:51:56 +02:00
Andras Bacsai 501e6a2650 refactor(environment): standardize service name formatting by replacing '-' and '.' with '_' in environment variable keys 2025-09-11 13:59:02 +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 a0bc4dac55 fix(application): streamline environment variable updates for Docker Compose services and enhance FQDN generation logic 2025-08-12 10:06:19 +02:00
Andras Bacsai 90ccaeba51 feat(application): implement environment variable updates for Docker Compose applications, including creation, updating, and deletion of SERVICE_FQDN and SERVICE_URL variables 2025-07-18 20:48:56 +02:00
Andras Bacsai 5e693eb4b5 refactor(services): simplify environment variable updates by using updateOrCreate and add cleanup for removed FQDNs 2025-07-18 20:48:56 +02:00
Andras Bacsai 9ed77e5eef fix(services): update environment variable naming convention to use underscores instead of dashes for SERVICE_FQDN and SERVICE_URL 2025-07-18 20:48:56 +02:00
Andras Bacsai 2a9d499251 feat: migrate env variables to polymorphic relationship
fix: proxy status query ui
2024-12-17 10:38:42 +01:00
Lucas Michot 1ec224fde1 Inline many variables. 2024-10-31 18:20:11 +01:00
Lucas Michot 601f1a4717 Always prefer stricter string comparisons. 2024-10-31 15:23:19 +01:00
Lucas Michot c5403b0b3f Always prefer ::class notation 2024-10-28 14:56:13 +01:00
Andras Bacsai 1d72f76072 fix: appwrite template + parser 2024-09-09 15:04:51 +02:00
Andras Bacsai 7d7cdf41f7 fix: storages with preserved git repository 2024-08-21 14:31:17 +02:00
Andras Bacsai 6da359bc60 fix: empty string content should be saved as a file 2024-08-07 12:58:32 +02:00
Andras Bacsai 76c39a987c fix: service_url should not have a trailing slash 2024-08-05 13:42:51 +02:00
Andras Bacsai d7350fad76 fix: several shared environment variables in one value, parsed correctly 2024-07-26 13:22:44 +02:00
Andras Bacsai 0e0c81c32b fix: update SERVICE_FQDN/URL env variables when you change the domain 2024-07-26 11:58:40 +02:00
Andras Bacsai 320204d854 fix: directory will be created by default for compose host mounts 2024-07-22 15:10:07 +02:00
Andras Bacsai 43409f3ff0 fix: add validation for missing docker compose file 2024-07-15 11:31:18 +02:00
Andras Bacsai 28c7e439b1 fix: service domains and envs are properly updated 2024-07-15 10:55:04 +02:00
Andras Bacsai 6c33bd9c72 openapi services 2024-07-09 13:30:13 +02:00
Andras Bacsai 2c92cc40e1 refactor: Update code to use str() instead of Str::of() for string manipulation 2024-06-25 10:37:10 +02:00
Thijmen d86274cc37 Fix styling 2024-06-10 20:43:34 +00:00
Andras Bacsai 0ddd5f0a79 refactor: Remove unnecessary port appending in updateCompose function 2024-05-31 10:55:08 +02:00
iamEvan 71e32520cf fix: SERVICE_FQDN has source port in it 2024-05-30 20:05:44 +01:00
Andras Bacsai 80ada9c90a fix: add subpath for services 2024-05-22 15:45:30 +02:00
Andras Bacsai 11baa97ef6 Refactor services.php file to improve variable replacement logic 2024-04-29 12:04:32 +02:00
Andras Bacsai b71f1a79c8 revert: variable parsing 2024-04-26 21:11:40 +02:00
Andras Bacsai 9a9be466f7 Refactor replaceVariables function in services.php to use a more concise syntax 2024-04-26 13:49:38 +02:00
Andras Bacsai 35b07a9c18 Refactor code to add sudo prefix for certain commands in multiple files 2024-04-17 10:49:34 +02:00