4

So I am trying to use deployer to deploy my local files to a server.

However I am not sure how deployer exactly works, because it seems like it needs a GIT repository - which I do not want to use. In the documentation I can't really find much information about my issue.

My Question: How do I use deployer without git-repository. Just push my local files to the server / multiple servers.

I use Symfony4 with deployer installed and everything works fine until following error:

fatal: repository '/var/www/project/releases/1' does not exist

Thanks


deployer.php

<?php
namespace Deployer;

require 'recipe/symfony.php';

// Project name
set('application', 'project');

// Project repository
//set('repository', '');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);

// Shared files/dirs between deploys 
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server 
add('writable_dirs', []);
set('allow_anonymous_stats', false);

// Hosts

host('x.x.x.x') //IP of host
    ->user('www-data')
    ->set('deploy_path', '/var/www/project');

// Tasks

task('build', function () {
    run('cd {{release_path}} && build');
});

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'database:migrate');
Syllz
  • 290
  • 6
  • 22
  • How does your deployer config look like? – paskl Aug 01 '19 at 08:15
  • @paskl I've updated my question. Basically the base-config file with my own host. – Syllz Aug 01 '19 at 08:19
  • Deployer issues tasks of your recipe automatically. See https://github.com/deployphp/deployer/blob/master/recipe/symfony.php#L142. So you could overwrite the task which gives you trouble. Or ignore it entirely. – paskl Aug 01 '19 at 08:21
  • @paskl sadly this happens in the update_code part - which seems to be necessary in order to work. But I did indeed change my recipe from symfony to symfony4. Sadly same problem - since I have no repository. – Syllz Aug 01 '19 at 08:43
  • You can overwrite that, too. Just redfine that task with your own functionality. – paskl Aug 01 '19 at 08:50

2 Answers2

4

Like stated above, you can use the rsync recipe or simply override the deploy:update_code with something like this:

task('deploy:update_code', function () {
    writeln("<info>Uploading files to server</info>");
    upload('./< some path >', '{{release_path}}');
});

Sometimes I just need to push some files to remote and I created a task for that purpose:

use Symfony\Component\Console\Input\InputOption;

option('source', null, InputOption::VALUE_OPTIONAL, 'Source alias of the current task.');
option('target', null, InputOption::VALUE_OPTIONAL, 'Target alias of the current task.');

task('upload:file', function() {
    /*
    * Usage: dep upload:file --source="some_destination/file.txt" --target="some_destination/" host
    */

    $source = null;
    $target = null;

    if (input()->hasOption('source')) {
        $source = input()->getOption('source');
    }

    if (input()->hasOption('target')) {
        $target = input()->getOption('target');
    }
    if (askConfirmation('Upload file ' . $source . ' to release/' . $target . ' ?')) {
        upload('/< some place >' . $source, '{{release_path}}/' . $target);
    }
});
tmsss
  • 1,979
  • 19
  • 23
1

If you don't want to write a deployment task from scratch, the deployer/recipes package provides the rsync recipe that will allow to transfer your project to your hosts without the need for git.

UPDATE: deployer/recipes has been deprecated and no longer available for 7.x. The recipe is now bundled in the contrib directory of the main package.

msg
  • 7,863
  • 3
  • 14
  • 33