Neos/Surf-Deployment How to start

Hi.

I have successfully setup an Neos installation and now I am trying to edit some content of the Demo project “TYPO3.NeosDemoTypo3Org”.

After a couple of hours doing research I have found “Surf”-deployment to fulfill my needs. So I started to setup a git repository with a couple of files in it. I also have setup a deployment script which is running fine for my testing environment.

Unfortunately I am not able to deploy my local changes to the remote testing environment. I did a “./flow site:export --package-name TYPO3.NeosDemoTypo3Org” for several times, so I can put the Sites.xml in the git repository. Am I missing some files to checkin?

So I want to ask you how to start a successful deployment of my local changes to the Demo project.

  1. Which files are necessary in the git repository, to do a versioning of my local changes?
  2. Which files are necessary in the git repository for a deployment, so my local changes are visible in my testing environment?

Thanks in advance.

Kind Regards.

Sorry, I don’t really understand what precise problems you’re having, but maybe this article would help you: http://dimaip.github.io/2014/12/20/three-steps-to-deploy/

And here’s our production deployment setup:

  1. https://github.com/sfi-ru/SfiDistr/blob/master/circle.yml
  2. https://github.com/sfi-ru/Surf/blob/master/Build/Surf/Surf.php

You can also check million12/typo3-flow-neos-abstract Docker container which also supports Surf deployments.

PS. Unless you’re fluent with Docker, I really recommend you to first master Surf itself, only then try to containerize your app.

Hi Dmitri, Hi Marcin,

to dive more into my setup I will give you a few explanations.

I have setup two identical Neos installations. One local setup (internal self hosted Ubuntu server) and one remote setup (external Ubuntu server with ssh-based access).
On local setup I do all my changes in Neos, e.g. edit some templates, add some packages, add pages and more). These changes I want to deploy to my remote setup, so they are in the exact same state.

I did an installation of the Surf package on my local server and setup the following deployment script.

<?php

    use \TYPO3\Surf\Domain\Model\Node;
    use \TYPO3\Surf\Domain\Model\SimpleWorkflow;

    $node = new Node('production');
    $node->setHostname('my-hostname');
    $node->setOption('username', 'my-username');

    $application = new \TYPO3\Surf\Application\TYPO3\Neos();
    $application->setDeploymentPath('/var/www/virtual');
    $application->setContext('Production');
    $application->setOption('composerCommandPath', '/usr/local/bin/composer');
    $application->setOption('repositoryUrl', 'ssh://git-user@gitlab:22/path/repository.git');
    $application->setOption('transferMethod', 'git');
    $application->setOption('keepReleases', 5);
    $application->setOption('sitePackageKey', 'TYPO3.NeosDemoTypo3Org');

    $workflow = new SimpleWorkflow();
    $workflow->setEnableRollback(TRUE);
    $deployment->setWorkflow($workflow);

    $application->addNode($node);
    $deployment->addApplication($application);

The Surf-Deployment itself runs fine without errors. But unfortunatelly my newly added content from local setup does not exist on remote setup after all.

So my question is, what kind of files do I need to add to my Git-repository, so my edited content and packages will be up on remote machine?

Thanks for your help.

Kind regards.

Hi Tim,

you might want to export your site content into your Git repository, create a new commit and then do a site:import in the Surf deployment. This should update your remote server with the latest content. If you don’t include your site package in your Git repository (so you have a combined repository for your Neos distribution and the site package) you need to export the site into a file:

./flow site:export --filename Path/To/Sites.xml
git add Path/To/Sites.xml
git commit -m "New content"
git push

The Surf Neos application adds a typo3.surf:typo3:neos:importsite task automatically which uses the configured sitePackageKey to import the content. This task doesn’t support the filename argument yet. So what I’d do in that case is to remove the original task and add a typo3.surf:typo3:flow:runcommand task which imports the content from the specific Sites.xml:

$deployment->onInitialize(function() use ($deployment) {
	/** @var $workflow \TYPO3\Surf\Domain\Model\Workflow */
	$workflow = $deployment->getWorkflow();

	$workflow->removeTask('typo3.surf:typo3:neos:importsite');

	$workflow->defineTask('my.project:site:import', 'typo3.surf:typo3:flow:runcommand', array('command' => 'site:import --filename Path/To/Sites.xml'));
	$workflow->addTask('my.project:site:import', 'migrate');
});

Didn’t test that script above but that should be the basic structure you need to use. We should improve the Surf Neos application and the site import task to support that case without customization though. We don’t actually use the Neos application because in production deployments we don’t want a site import to happen. So that should be configurable, too.