Skip to content

Commit

Permalink
Hotfix/v7.4.0: Fixes caddyfile and realpath errors in provision:websi…
Browse files Browse the repository at this point in the history
…te (#3837)

* Hotfix: Fixed file read error in website.php

Moved the directory creation and ownership setting code before the file read operation to prevent the file read error.

* Hotfix: Adjusted Caddyfile path and ensured its inclusion in build

* Regenerate docs using php bin/docgen
  • Loading branch information
midhunmonachan authored May 21, 2024
1 parent 6db3a10 commit 5edee95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
7 changes: 5 additions & 2 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,18 @@ foreach ($iterator as $fileInfo) {
// Add schema.json
echo "Add file: /src/schema.json\n";
$phar->addFile(realpath(__DIR__ . '/../src/schema.json'), '/src/schema.json');

// Add Caddyfile
echo "Add file: /Caddyfile\n";
$phar->addFile(realpath(__DIR__ . '/../recipe/provision/Caddyfile'), '/recipe/provision/Caddyfile');
// Add bin/dep file
echo "Add file: /bin/dep\n";
$depContent = file_get_contents(__ROOT__ . '/bin/dep');
$depContent = str_replace("#!/usr/bin/env php\n", '', $depContent);
$depContent = str_replace('__FILE__', 'str_replace("phar://", "", Phar::running())', $depContent);
$depContent = preg_replace("/run\('.+?'/", "run('$version'", $depContent);
$phar->addFromString('bin/dep', $depContent);
$phar->setStub(<<<STUB
$phar->setStub(
<<<STUB
#!/usr/bin/env php
<?php
Phar::mapPhar('{$pharName}');
Expand Down
10 changes: 5 additions & 5 deletions docs/recipe/provision/website.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require 'recipe/provision/website.php';

## Configuration
### domain
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L4)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L7)



Expand All @@ -23,7 +23,7 @@ return ask(' Domain: ');


### public_path
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L8)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L11)



Expand All @@ -36,23 +36,23 @@ return ask(' Public path: ', 'public');
## Tasks

### provision:website
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L13)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L16)

Provision website.




### logs:caddy
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L54)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L56)

Shows caddy logs.




### logs:caddy:syslog
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L59)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/provision/website.php#L61)

Shows caddy syslog.

Expand Down
11 changes: 6 additions & 5 deletions recipe/provision/website.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Deployer;

set('domain', function () {
Expand All @@ -11,17 +14,16 @@

desc('Provision website');
task('provision:website', function () {
set('deploy_path', run("realpath {{deploy_path}}"));

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

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

run("[ -d log ] || mkdir log");
run("chgrp caddy log");

$caddyfile = parse(file_get_contents('./Caddyfile'));
$caddyfile = parse(file_get_contents(__DIR__ . '/Caddyfile'));

if (test('[ -f Caddyfile ]')) {
run("echo $'$caddyfile' > Caddyfile.new");
Expand Down Expand Up @@ -59,4 +61,3 @@
task('logs:caddy:syslog', function () {
run('sudo journalctl -u caddy -f');
})->verbose();

0 comments on commit 5edee95

Please sign in to comment.