-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Error Message and Logs
Preview deployments (pull request deployments) for static websites fail with the error:
ERROR: failed to build: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
Regular deployments of the same static site work correctly.
Steps to Reproduce
- Create an application with
build_packset to'static' - Configure the application to deploy from a Git repository
- Enable preview deployments for the application
- Create a pull request in the connected repository
- Trigger a preview deployment
Example Repository URL
No response
Coolify Version
v4.0.0-beta.462
Are you using Coolify Cloud?
No (self-hosted)
Operating System and Version (self-hosted)
No response
Additional Information
The issue is in the deployment routing logic in ApplicationDeploymentJob.php:
Main Deployment Handler (lines 462-476)
} elseif ($this->pull_request_id !== 0) {
$this->deploy_pull_request(); // ← All preview deployments go here
} elseif ($this->application->dockerfile) {
$this->deploy_simple_dockerfile();
} elseif ($this->application->build_pack === 'dockercompose') {
$this->deploy_docker_compose_buildpack();
} elseif ($this->application->build_pack === 'dockerimage') {
$this->deploy_dockerimage_buildpack();
} elseif ($this->application->build_pack === 'dockerfile') {
$this->deploy_dockerfile_buildpack();
} elseif ($this->application->build_pack === 'static') {
$this->deploy_static_buildpack(); // ← Regular static deployments go here
} else {
$this->deploy_nixpacks_buildpack();
}Problem: When pull_request_id !== 0, the code immediately calls deploy_pull_request() without checking the build_pack type. This bypasses all build pack-specific routing.
Preview Deployment Handler (lines 1878-1913)
private function deploy_pull_request()
{
if ($this->application->build_pack === 'dockercompose') {
$this->deploy_docker_compose_buildpack();
return;
}
// ← Missing: No check for 'static' build pack!
if ($this->use_build_server) {
$this->server = $this->build_server;
}
$this->newVersionIsHealthy = true;
$this->generate_image_names();
$this->application_deployment_queue->addLogEntry("Starting pull request (#{$this->pull_request_id}) deployment...");
$this->prepare_builder_image();
$this->check_git_if_build_needed();
$this->clone_repository();
$this->cleanup_git();
if ($this->application->build_pack === 'nixpacks') {
$this->generate_nixpacks_confs();
}
$this->generate_compose_file();
$this->save_buildtime_environment_variables();
$this->generate_build_env_variables();
if ($this->application->build_pack === 'dockerfile') {
$this->add_build_env_variables_to_dockerfile();
}
$this->build_image(); // ← This expects a Dockerfile, which static sites don't have
// ...
}Problem: The deploy_pull_request() method:
- Has special handling for
dockercomposebuild pack - Has special handling for
dockerfileandnixpacksbuild packs - Missing: No special handling for
staticbuild pack - Defaults to calling
build_image()which expects a Dockerfile
For static sites, it should call build_static_image() instead, which creates an inline Dockerfile that copies static files to an nginx image.
Proposed Fix
Add a check for the static build pack in the deploy_pull_request() method, immediately after the dockercompose check:
File: app/Jobs/ApplicationDeploymentJob.php
Location: Line 1878-1887
Change:
private function deploy_pull_request()
{
if ($this->application->build_pack === 'dockercompose') {
$this->deploy_docker_compose_buildpack();
return;
}
// ADD THIS BLOCK ↓
if ($this->application->build_pack === 'static') {
$this->deploy_static_buildpack();
return;
}
// END NEW BLOCK ↑
if ($this->use_build_server) {
$this->server = $this->build_server;
}
// ... rest of the method
}Why This Fix Works
- Consistency: The fix makes preview deployments respect the
build_packconfiguration, just like regular deployments - Reuses Existing Logic:
deploy_static_buildpack()already has all the correct logic for static deployments:- Uses
build_static_image()which creates an inline Dockerfile - Copies static files to the nginx base image
- Handles build-time and runtime environment variables correctly
- Uses
- Follows Existing Pattern: The fix mirrors the existing
dockercomposecheck, maintaining code consistency