deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box
https://deployer.org
MIT License
10.56k stars 1.48k forks source link

Bugs related to provision:website #3836

Closed midhunmonachan closed 4 months ago

midhunmonachan commented 4 months ago

I repeatedly encountered this error while running provision with deployer v7.4.0 on a clean Ubuntu 20.04 installation


> task provision:website
[beta.midhun.ca]  ErrorException  in website.php on line 26:
[beta.midhun.ca]
[beta.midhun.ca]   file_get_contents(./Caddyfile): Failed to open stream: No such file or directory
[beta.midhun.ca]
ERROR: Task provision:website failed!

I managed to fix it by:

  1. Adding _DIR_ to file reference resulting in file_get_contents(__DIR__ . '/Caddyfile')
  2. Adding Caddyfile to the build

echo "Add file: /Caddyfile\n";
$phar->addFile(realpath(__DIR__ . '/../recipe/provision/Caddyfile'), '/recipe/provision/Caddyfile');

Then i encountered another error:


> task provision:website
[beta.midhun.ca]  error  in website.php on line 17:
[beta.midhun.ca] run realpath /var/www/somehostname
[beta.midhun.ca] err realpath: /var/www/somehostname: No such file or directory
[beta.midhun.ca] exit code 1 (General error)
ERROR: Task provision:website failed!

This is where the error happened:


set('deploy_path', run("realpath {{deploy_path}}"));

run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}");
run("chown -R deployer:deployer {{deploy_path}}");

Upon further testing, this happens when /var/www directory is not present.

_So if the parent directory of the deploy_path is absent, this error occurs._

I moved set('deploy_path', run("realpath {{deploy_path}}")); after run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); to make sure realpath runs after creating the directory

It seems like code sequence got mixed up when looking at the source provision:website in recipe/provision/website.php.

These fixes the issues i had. I'm working on a PR.


Discussed in https://github.com/deployphp/deployer/discussions/3821

Originally posted by **mariomka** April 23, 2024 - Deployer version: 7.4.0 - Deployment OS: Ubuntu 20.04 I'm trying to provision a clean server in Hetzner Cloud (CCX13 - dedicated 2 vCPU 8GB RAM) with the Laravel recipe. I got an error; I tried several times with different PHP versions and removed and created the server. The error is the following: ``` [servername] ErrorException in website.php on line 24: [servername] [servername] file_get_contents(./Caddyfile): Failed to open stream: No such file or directory [servername] ERROR: Task provision:website failed! ``` The `deploy.yaml` file: ```yaml import: - recipe/laravel.php config: repository: 'git@github.com:XXX/xxx' hosts: servername: remote_user: deployer deploy_path: '/var/www/my-project' tasks: build: - run: uptime after: deploy:failed: deploy:unlock ```