Commit graph

687 commits

Author SHA1 Message Date
Andras Bacsai
ab1958d741 fix(railpack): fail fast when buildx is unavailable
Require Docker buildx before Railpack builds, normalize environment
variable keys before validation, and align private deploy key API docs with
the supported dockerfile build pack.
2026-05-11 17:31:29 +02:00
Andras Bacsai
b5ff124446 fix(env): validate Docker-compatible variable keys
Add shared environment variable key validation and normalization for Livewire forms and models, allowing Docker-compatible keys while rejecting invalid entries such as keys containing equals signs. Also quote Railpack build environment and secret arguments safely.
2026-05-11 15:43:09 +02:00
Andras Bacsai
d5946dcfca fix(railpack): include scoped env vars in builds
Build Railpack variables from generic build-time vars plus Railpack-specific vars, filter unrelated buildpack control vars, and ensure curl/wget deploy apt packages are present. Add coverage for standard and preview deployments.
2026-05-11 13:29:21 +02:00
Andras Bacsai
b6ca6b1b20 feat(railpack): expose COOLIFY_* vars at build time and generalize buildpack control flag
Mirrors Nixpacks behavior: inject COOLIFY_* and SOURCE_COMMIT into
railpack build variables so apps (e.g. SPAs baking public URLs) can
read them via /run/secrets/<KEY>.

Rename is_nixpacks → is_buildpack_control to cover both NIXPACKS_ and
RAILPACK_ prefixed keys. Update the env variable view and appends list
accordingly.

Promote generate_coolify_env_variables to protected for testability.
2026-04-30 18:31:41 +02:00
Andras Bacsai
ace643d3d8 fix(railpack): query buildtime env vars directly instead of via computed attribute
Replace `railpack_environment_variables_collection()` helper (which returned
pre-filtered Eloquent attribute collections) with inline queries on
`environment_variables()` / `environment_variables_preview()` filtered by
`is_buildtime`. This ensures Railpack build variables are sourced from the
same query path as the rest of the deployment pipeline and avoids relying on
a now-removed accessor that silently included all railpack vars regardless of
build context.
2026-04-30 16:38:58 +02:00
Andras Bacsai
ec71d33f5e fix(railpack): pin frontend image version via config constant
Remove RAILPACK_FRONTEND_IMAGE env var from helper Dockerfile and resolve
the image ref at runtime using a new `railpack_version` constant in config.
Eliminates Docker build-time env interpolation for BUILDKIT_SYNTAX arg.
2026-04-30 16:27:08 +02:00
Andras Bacsai
28320858ca feat(railpack): log generated config and build plan, add multi-language dev examples
Log Railpack config JSON (dev-only) after generation and capture
railpack-plan.json post-prepare step. In prod, strip secrets array
before logging. In dev, log full plan.

Add 10 multi-language seeder examples (Python/Flask, Go/Gin, Rust,
Laravel, Symfony, Rails, Elixir/Phoenix, Bun) targeting v4.x branch.
Support per-example git_branch override in upsertApplication.
2026-04-30 15:22:15 +02:00
Andras Bacsai
b3339d1034 feat(railpack): add buildpack control var filtering and dev seeder
Extract NIXPACKS_/RAILPACK_ prefix filtering into a reusable
`scopeWithoutBuildpackControlVariables` query scope on EnvironmentVariable.
Apply scope consistently to runtime vars, runtime preview vars, and
buildtime var generation in ApplicationDeploymentJob.

Refactor `generate_railpack_env_variables` to return a Collection.
Add `RAILPACK_FRONTEND_IMAGE` constant and bake it into the
coolify-helper Dockerfile as a build arg.

Add DevelopmentRailpackExamplesSeeder (dev/local env only) for
seeding example Railpack apps, wired into DatabaseSeeder.

Add tests:
- ApplicationDeploymentControlVarFilteringTest: verifies control vars
  are excluded from runtime and buildtime envs
- DevelopmentRailpackExamplesSeederTest: verifies seeder behavior
- ApplicationDeploymentRailpackEnvParityTest: parity checks for env
  handling across build/runtime paths
2026-04-28 14:37:31 +02:00
Andras Bacsai
5cef7cc092 Merge remote-tracking branch 'origin/next' into feat/railpack 2026-04-28 14:36:54 +02:00
nehemiyawicks
36baf70637 fix: use --network host for Dockerfile buildpack builds
Dockerfile buildpack was passing --network {custom_network_name} to
docker build, but BuildKit only supports host, none, and default.
Every other buildpack already uses --network host with --add-host
flags. Aligned the Dockerfile path to match.

Fixes #9804
2026-04-26 19:30:05 +05:30
Andras Bacsai
451b7376ed Merge remote-tracking branch 'origin/next' into feat/railpack 2026-04-17 07:01:27 +02:00
Andras Bacsai
9f86b73d65
fix(healthcheck): user input is rejected if path contains comma and semicolon (#9223) 2026-04-14 10:41:55 +02:00
Andras Bacsai
3c51b1aacc fix(railpack): pass command overrides through supported prepare/build args
Use Railpack's install env handling and dedicated CLI flags for build/start overrides, and forward install commands into docker build secrets so image builds stay aligned with prepare-time configuration. Update the railpack config test to cover the new command format.
2026-04-09 19:01:52 +02:00
Andras Bacsai
d7e1b7ec37 feat(railpack): add config merging, beta badge, and nodejs seeder example
- Implement railpack.json + generated config deep merging logic in
  ApplicationDeploymentJob with JSON validation and assoc array checks
- Label Railpack as "Beta" in all build pack selectors and show a
  visible beta badge when railpack is selected in new-app forms
- Add railpack-nodejs Fastify example to ApplicationSeeder
- Add ApplicationSeederTest and ApplicationDeploymentRailpackConfigTest
  covering config merge behavior and seeder correctness
2026-04-09 18:45:42 +02:00
Andras Bacsai
18508e9149 fix(railpack): pass build and start commands via --env instead of dedicated flags
Replace --build-cmd and --start-cmd with --env RAILPACK_BUILD_CMD and
--env RAILPACK_START_CMD to align with how install_command is already
passed, matching the expected railpack CLI interface.
2026-04-09 17:13:26 +02:00
Andras Bacsai
f573ad28a0 Merge remote-tracking branch 'origin/next' into feat/railpack 2026-04-09 17:12:26 +02:00
Andras Bacsai
2abb073b52 Merge remote-tracking branch 'origin/next' into 9076-investigate-pre-deployment 2026-03-31 16:49:43 +02:00
Andras Bacsai
30751a60df fix(deployment): resolve shared env vars using main server
Use `$this->mainServer` when resolving environment variable values across
deployment env generation (runtime, buildtime, nixpacks, args, and secrets
hash) so shared server-scoped values are applied consistently.

Also add `server_id` to `SharedEnvironmentVariable::$fillable` and normalize
the Livewire Blade file newline.
2026-03-31 11:07:52 +02:00
Andras Bacsai
cb97a18a78 Merge remote-tracking branch 'origin/next' into pr-7764-shadow/add-shared-server-env 2026-03-31 10:52:31 +02:00
Andras Bacsai
61f47cc7ee feat(deployments): support Docker image tags for preview deployments
Add end-to-end support for `docker_registry_image_tag` in preview and deployment queue flows.

- Extend deploy API to accept `pull_request_id` alias and `docker_tag` for preview deploys
- Persist preview-specific Docker tags on `application_previews` and `application_deployment_queues`
- Pass tag through `queue_application_deployment()` and de-duplicate queued jobs by tag
- Update deployment job logic to resolve and use preview Docker tags for dockerimage build packs
- Update Livewire previews UI/state to manage per-preview tags and manual preview/tag inputs
- Add migration for new tag columns and model fillable/casts updates
- Add feature and unit tests covering API behavior and tag resolution
2026-03-30 13:35:35 +02:00
Andras Bacsai
3d1b9f53a0 fix: add validation and escaping for Docker network names
Add strict validation for Docker network names using a regex pattern
that matches Docker's naming rules (alphanumeric start, followed by
alphanumeric, dots, hyphens, underscores).

Changes:
- Add DOCKER_NETWORK_PATTERN to ValidationPatterns with helper methods
- Validate network field in Destination creation and update Livewire components
- Add setNetworkAttribute mutator on StandaloneDocker and SwarmDocker models
- Apply escapeshellarg() to all network field usages in shell commands across
  ApplicationDeploymentJob, DatabaseBackupJob, StartService, Init command,
  proxy helpers, and Destination/Show
- Add comprehensive tests for pattern validation and model mutator

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 12:28:59 +01:00
ShadowArcanist
b18de3af9a fix(healthcheck): accept comma and semicolon in health check path validation 2026-03-28 16:31:12 +05:30
Andras Bacsai
ad95d65aca
fix(deployment): normalize whitespace in pre/post deployment commands (#9173) 2026-03-25 20:59:18 +01:00
Andras Bacsai
6f163ddf02 fix(deployment): normalize whitespace in pre/post deployment commands
Ensure pre_deployment_command and post_deployment_command have consistent
whitespace handling, matching the existing pattern used for health_check_command.
Adds regression tests for the normalization behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 20:57:17 +01:00
Andras Bacsai
333cc9589d feat(deployment): add command_hidden flag to hide command text in logs
Add support for hiding sensitive command text while preserving output logs.
When command_hidden is true, the command text is set to null in the main log
entry but logged separately to the deployment queue with proper redaction.

- Add command_hidden parameter to execute_remote_command and executeCommandWithProcess
- When enabled, separates command visibility from output visibility
- Fix operator precedence in type ternary expression
2026-03-25 16:48:49 +01:00
Andras Bacsai
207002dbb7 Merge remote-tracking branch 'origin/next' into feat/railpack 2026-03-25 16:45:30 +01:00
Andras Bacsai
811ee5d327 refactor(jobs): extract container resolution logic for deployment commands
Extract common container selection logic into resolveCommandContainer() method
that handles both single and multi-container app scenarios. This consolidates
duplicated code from run_pre_deployment_command() and run_post_deployment_command()
while improving error messaging and test coverage.
2026-03-25 14:09:07 +01:00
Andras Bacsai
3034e89edb feat(preview-env): add production variable fallback for docker-compose
When preview environment variables are configured, fall back to production
variables for keys not overridden by preview values. This ensures variables
like DB_PASSWORD that exist only in production are available in the preview
.env file, enabling proper ${VAR} interpolation in docker-compose YAML.

Fallback only applies when preview variables are configured, preventing
unintended leakage of production values when previews aren't in use.

Also improves UI by hiding the Domains section when only database services
are present, and simplifies the logs view by removing status checks.
2026-03-25 13:26:50 +01:00
Andras Bacsai
4afcbbb209 fix(deployment): properly escape shell arguments in railpack prepare command 2026-03-24 07:09:24 +01:00
Andras Bacsai
2ed360f0e0 Merge remote-tracking branch 'origin/next' into feat/railpack 2026-03-23 21:58:33 +01:00
Andras Bacsai
dac940807a fix(deployment): properly escape shell arguments in nixpacks commands
Add escapeShellValue() helper function to safely escape shell values by wrapping
them in single quotes and escaping embedded quotes. Use this function throughout
the nixpacks command building to prevent shell injection vulnerabilities when
passing user-provided build commands, start commands, and environment variables.

This fixes unsafe string concatenation that could allow command injection when
user input contains special shell characters like &&, |, ;, etc.
2026-03-23 21:55:46 +01:00
Aditya Tripathi
cddbaf581f refactor(railpack): extract static image build, fix port logic, bump to v0.22.0
Extract build_railpack_static_image() into its own method, prevent port
override when is_static is set, bump Railpack to 0.22.0, and improve
test setup with beforeEach and correct polymorphic env var fields.
2026-03-23 19:02:10 +00:00
Aditya Tripathi
793077d74f feat(buildpack): add Railpack as a build pack option 2026-03-23 17:12:02 +00:00
Andras Bacsai
8be226788e
fix(deployment): disable build server during restart operations (#9045) 2026-03-20 16:16:46 +01:00
Andras Bacsai
65ed407ec8 fix(deployment): disable build server during restart operations
The just_restart() method doesn't need the build server—disabling it ensures
the helper container is created on the deployment server with the correct
network configuration and flags. The build server setting is restored before
should_skip_build() is called in case it triggers a full rebuild that requires it.
2026-03-19 23:42:11 +01:00
Andras Bacsai
23f9156c73 Squashed commit from 'qqrq-r9h4-x6wp-authenticated-rce' 2026-03-18 13:53:01 +01:00
Andras Bacsai
2ba62ffe02 Merge remote-tracking branch 'origin/next' into next 2026-03-16 21:22:32 +01:00
Andras Bacsai
0ffcee7a4d Squashed commit from '4fhp-investigate-os-command-injection' 2026-03-16 16:40:16 +01:00
Andras Bacsai
add16853a8 feat(preview): add configurable PR suffix toggle for volumes
Add `is_preview_suffix_enabled` flag to `local_file_volumes` and
`local_persistent_volumes` tables, allowing per-volume control over
whether a `-pr-N` suffix is appended during preview deployments.

Defaults to `true` to preserve existing behavior. Users can disable
it for volumes containing shared config or repository scripts that
should not be isolated per PR.
2026-03-16 14:54:22 +01:00
Andras Bacsai
a97612b29e fix(docker-compose): respect preserveRepository when injecting --project-directory
When adding --project-directory to custom docker compose start commands,
use the application's host workdir if preserveRepository is true, otherwise
use the container workdir. Add tests for both scenarios and explicit paths.
2026-03-13 13:53:03 +01:00
Andras Bacsai
aac34f1d14 fix(git-import): explicitly specify ssh key and remove duplicate validation rules
- Add -i flag to explicitly specify ssh key path in git ls-remote operations
- Remove static $rules properties in favor of dynamic rules() method
- Fix test syntax error
2026-03-12 14:19:53 +01:00
Andras Bacsai
01031fc5f3 refactor: consolidate file path validation patterns and support scoped packages
- Extract file path validation regex into ValidationPatterns::FILE_PATH_PATTERN constant
- Add filePathRules() and filePathMessages() helper methods for reusable validation
- Extend allowed characters from [a-zA-Z0-9._\-/] to [a-zA-Z0-9._\-/~@+] to support:
  - Scoped npm packages (@org/package)
  - Language-specific directories (c++, rust+)
  - Version markers (v1~, build~)
- Replace duplicate inline regex patterns across multiple files
- Add tests for paths with @ symbol and tilde/plus characters
2026-03-12 13:09:13 +01:00
Andras Bacsai
a7f491170a fix(deployment): filter null and empty environment variables from nixpacks plan
When application->fqdn is null, COOLIFY_FQDN and COOLIFY_URL are set to null.
These null values cause nixpacks to fail parsing the config with
"invalid type: null, expected a string".

Filter out null and empty string values when generating environment variables
for the nixpacks plan JSON. Fixes #6830.
2026-03-11 13:41:34 +01:00
Andras Bacsai
76084ce69b chore: prepare for PR 2026-03-11 08:57:12 +01:00
Andras Bacsai
7aa744af90 chore: prepare for PR 2026-03-11 06:38:40 +01:00
Andras Bacsai
a1c30cb0e7 fix(git-ref-validation): prevent command injection via git references
Add validateGitRef() helper function that uses an allowlist approach to prevent
OS command injection through git commit SHAs, branch names, and tags. Only allows
alphanumeric characters, dots, hyphens, underscores, and slashes.

Changes include:
- Add validateGitRef() helper in bootstrap/helpers/shared.php
- Apply validation in Rollback component when accepting rollback commit
- Add regex validation to git commit SHA fields in Livewire components
- Apply regex validation to API rules for git_commit_sha
- Use escapeshellarg() in git log and git checkout commands
- Add comprehensive unit tests covering injection payloads

Addresses GHSA-mw5w-2vvh-mgf4
2026-03-10 22:22:48 +01:00
Andras Bacsai
e3daba0b1d chore: prepare for PR 2026-03-10 09:43:29 +01:00
Andras Bacsai
3e755338b4 fix(healthchecks): remove redundant newline sanitization from CMD healthcheck
Simplify the CMD healthcheck generation by removing the str_replace call that
normalizes newlines. The command is now used directly without modification,
following the pattern of centralized command escaping in recent changes.
2026-02-25 12:08:24 +01:00
Andras Bacsai
521d995ea1 Merge remote-tracking branch 'origin/next' into 7765-healthcheck-investigation 2026-02-25 11:57:58 +01:00
Andras Bacsai
57848c25e9
fix(docker): centralize command escaping in executeInDocker helper (#8615) 2026-02-25 11:51:23 +01:00