Skip to content

Commit

Permalink
Improve provision recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 19, 2024
1 parent b8a07fa commit 92fd453
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
38 changes: 19 additions & 19 deletions recipe/provision/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{{domain}} {
root * {{deploy_path}}/current/{{public_path}}
file_server
php_fastcgi * unix//run/php/php{{php_version}}-fpm.sock {
resolve_root_symlink
}
root * {{deploy_path}}/current/{{public_path}}
file_server
php_fastcgi * unix//run/php/php{{php_version}}-fpm.sock {
resolve_root_symlink
}

log {
output file {{deploy_path}}/log/access.log {
mode 0644
}
}
log {
output file {{deploy_path}}/log/access.log {
mode 0644
}
}

handle_errors {
@404 {
expression {http.error.status_code} == 404
}
rewrite @404 /404.html
file_server {
root /var/deployer
}
}
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
rewrite @404 /404.html
file_server {
root /var/deployer
}
}
}
6 changes: 5 additions & 1 deletion recipe/provision/nodejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace Deployer;

use function Deployer\Support\escape_shell_argument;
use function Deployer\Support\starts_with;

set('node_version', '23.x');

desc('Installs npm packages');
task('provision:node', function () {
set('remote_user', get('provision_user'));

if (has('nodejs_version')) {
throw new \RuntimeException('nodejs_version is deprecated, use node_version_version instead.');
}
Expand All @@ -22,6 +25,7 @@
}

$url = "https://github.com/Schniz/fnm/releases/latest/download/$filename.zip";
run("rm -rf /tmp/$filename.zip");
run("curl -sSL $url --output /tmp/$filename.zip");

run("unzip /tmp/$filename.zip -d /tmp");
Expand All @@ -30,6 +34,6 @@
run('chmod +x /usr/local/bin/fnm');

run('fnm install {{node_version}}');
appendToFile('/home/deployer/.bashrc', 'eval "`fnm env`"');
run("echo " . escape_shell_argument('eval "`fnm env`"') . " >> /etc/profile.d/fnm.sh");
})
->oncePerNode();
1 change: 1 addition & 0 deletions recipe/provision/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
run('chsh -s /bin/bash deployer');
run('cp /root/.profile /home/deployer/.profile');
run('cp /root/.bashrc /home/deployer/.bashrc');
run('touch /home/deployer/.sudo_as_admin_successful');

// Make color prompt.
run("sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/' /home/deployer/.bashrc");
Expand Down
15 changes: 0 additions & 15 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,18 +980,3 @@ function fetch(string $url, string $method = 'get', array $headers = [], ?string
}
return $http->send($info);
}


/**
* Appends a string to a file.
*
* @param string $file
* @param string $string
* @throws Exception
* @throws RunException
* @throws TimeoutException
*/
function appendToFile(string $file, string $string): void
{
run("echo " . escape_shell_argument($string) . " >> $file");
}

0 comments on commit 92fd453

Please sign in to comment.