Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Split up deployment section #342

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 6 additions & 126 deletions Documentation/Installation/DeployTYPO3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,129 +107,9 @@ When using a deployment tool this kind of directory structure is usually created

The following section contains examples for various deployment tools and how they can be configured to use TYPO3:

.. tabs::

.. tab:: TYPO3 Surf

:doc:`TYPO3 Surf <ext_surf:Index>` is a deployment tool written in PHP.


.. code-block:: php
:caption: ~/.surf/MyDeployment.php

<?php
/** @var \TYPO3\Surf\Domain\Model\Deployment $deployment */

$node = new \TYPO3\Surf\Domain\Model\Node('my.node.com');
$node
->setHostname($node->getName())
->setOption('username', 'myuser')
->setOption('phpBinaryPathAndFilename', '/usr/local/bin/php_cli');

$application = new \TYPO3\Surf\Application\TYPO3\CMS();
$application
->setDeploymentPath('/httpdocs')
->setOption('baseUrl', 'https://my.node.com/')
->setOption('webDirectory', 'public')
->setOption('symlinkDataFolders', ['fileadmin'])
->setOption('repositoryUrl', 'file://' . dirname(__DIR__))
->setOption('keepReleases', 3)
->setOption('composerCommandPath', 'composer')
->setOption('rsyncExcludes', [
'.ddev',
'.git',
$application->getOption('webDirectory') . '/fileadmin',
'packages/**.sass'
])
->setOption(TYPO3\Surf\Task\TYPO3\CMS\FlushCachesTask::class . '[arguments]', [])
->addSymlink($application->getOption('webDirectory') . '/config/system/settings.php', '../../../../shared/Configuration/settings.php')
->addNode($node);

$deployment
->addApplication($application)
->onInitialize(
function () use ($deployment, $application) {
$deployment->getWorkflow()
->beforeTask(\TYPO3\Surf\Task\TYPO3\CMS\SetUpExtensionsTask::class, \TYPO3\Surf\Task\TYPO3\CMS\CompareDatabaseTask::class, $application)
->beforeStage('transfer', \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, $application)
->afterStage('switch', \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class, $application)
// CreatePackageStatesTask is done by post-autoload-dump script and can be removed
// https://github.com/TYPO3/TYPO3.CMS.BaseDistribution/blob/9.x/composer.json#L38
->removeTask(\TYPO3\Surf\Task\TYPO3\CMS\CreatePackageStatesTask::class, $application)
->removeTask(\TYPO3\Surf\Task\TYPO3\CMS\CopyConfigurationTask::class, $application);
}
);


.. tab:: Deployer

`Deployer <https://deployer.org>`__ is an alternative deployment tool
written in PHP. A full description about how to get deployer running
for TYPO3 can be found at https://t3terminal.com/blog/typo3-deploy/

.. code-block:: php

<?php

namespace Deployer;

require_once(__DIR__ . '/vendor/sourcebroker/deployer-loader/autoload.php');
new \SourceBroker\DeployerExtendedTypo3\Loader();

set('repository', '[email protected]:youraccount/yourproject.git');
set('bin/php', '/home/www/example-project-directory/.bin/php');
set('web_path', 'public/');

host('live')
->hostname('production.example.org')
->user('deploy')
->set('branch', 'main')
->set('public_urls', ['https://production.example.org'])
->set('deploy_path', '/home/www/example-project-directory/live');


.. tab:: Magallanes

Yet another deployment tool for PHP applications written in PHP: https://www.magephp.com

.. code-block:: yaml
:caption: .mage.yml

magephp:
log_dir: ./.mage/logs
composer:
path: composer
exclude:
- ./.ddev
- ./.git
- ./.mage
- ./public/fileadmin
- ./public/typo3temp
- ./var
- ./.mage.yml
- ./composer.json
- ./composer.lock
- ./LICENSE
- ./README.md
environments:
main:
user: ssh-user
from: ./
host_path: /srv/vhosts/target-path/site/mage
releases: 3
hosts:
- production.example.org
pre-deploy:
- exec: { cmd: "composer install --no-dev --no-progress --optimize-autoloader"}
on-deploy:
- fs/link: { from: "../../../../shared/public/fileadmin", to: "public/fileadmin" }
- fs/link: { from: "../../../../shared/public/typo3temp", to: "public/typo3temp" }
- fs/link: { from: "../../../shared/var", to: "var" }
on-release:
post-release:
- exec: { cmd: './bin/typo3 backend:lock', timeout: 9000 }
- exec: { cmd: './bin/typo3cms database:updateschema *.add,*.change', timeout: 9000 }
- exec: { cmd: './bin/typo3cms cache:flush', timeout: 9000 }
- exec: { cmd: './bin/typo3 upgrade:run', timeout: 9000 }
- exec: { cmd: './bin/typo3 backend:unlock', timeout: 9000 }
post-deploy:
.. toctree::
:titlesonly:

Deployer/Index
Surf/Index
Magallanes/Index
17 changes: 17 additions & 0 deletions Documentation/Installation/Deployer/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. include:: /Includes.rst.txt

.. index:: Deployment; Deployer

.. _deployment-deployer:

========
Deployer
========

`Deployer <https://deployer.org>`__ is an alternative deployment tool
brotkrueml marked this conversation as resolved.
Show resolved Hide resolved
written in PHP. A full description about how to get deployer running
for TYPO3 can be found at https://t3terminal.com/blog/typo3-deploy/

.. literalinclude:: _deploy.php
:language: php
:caption: deploy.php
16 changes: 16 additions & 0 deletions Documentation/Installation/Deployer/_deploy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Deployer;

require_once(__DIR__ . '/vendor/sourcebroker/deployer-loader/autoload.php');
new \SourceBroker\DeployerExtendedTypo3\Loader();

set('repository', '[email protected]:youraccount/yourproject.git');
set('bin/php', '/home/www/example-project-directory/.bin/php');
set('web_path', 'public/');

host('live')
->hostname('production.example.org')
->user('deploy')
->set('branch', 'main')
->set('public_urls', ['https://production.example.org'])
->set('deploy_path', '/home/www/example-project-directory/live');
16 changes: 16 additions & 0 deletions Documentation/Installation/Magallanes/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. include:: /Includes.rst.txt

.. index:: Deployment; Magallanes

.. _deployment-magallanes:

==========
Magallanes
==========

Another deployment tool for PHP applications written in PHP: https://www.magephp.com/

.. literalinclude:: _mage.yml
:language: yaml
:caption: .mage.yml

39 changes: 39 additions & 0 deletions Documentation/Installation/Magallanes/_mage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
magephp:
log_dir: ./.mage/logs
composer:
path: composer
exclude:
- ./.ddev
- ./.git
- ./.mage
- ./public/fileadmin
- ./public/typo3temp
- ./var
- ./.mage.yml
- ./composer.json
- ./composer.lock
- ./LICENSE
- ./README.md
environments:
main:
user: ssh-user
from: ./
host_path: /srv/vhosts/target-path/site/mage
releases: 3
hosts:
- production.example.org
pre-deploy:
- exec: { cmd: "composer install --no-dev --no-progress --optimize-autoloader"}
on-deploy:
- fs/link: { from: "../../../../shared/public/fileadmin", to: "public/fileadmin" }
- fs/link: { from: "../../../../shared/public/typo3temp", to: "public/typo3temp" }
- fs/link: { from: "../../../shared/var", to: "var" }
on-release:
post-release:
- exec: { cmd: './bin/typo3 backend:lock', timeout: 9000 }
- exec: { cmd: './bin/typo3cms database:updateschema *.add,*.change', timeout: 9000 }
- exec: { cmd: './bin/typo3cms cache:flush', timeout: 9000 }
- exec: { cmd: './bin/typo3 upgrade:run', timeout: 9000 }
- exec: { cmd: './bin/typo3 backend:unlock', timeout: 9000 }
post-deploy:

17 changes: 17 additions & 0 deletions Documentation/Installation/Surf/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. include:: /Includes.rst.txt

.. index:: Deployment; TYPO3 Surf

.. _deployment-typo3-surf:

==========
TYPO3 Surf
==========

:doc:`TYPO3 Surf <ext_surf:Index>` is a deployment tool written in PHP.


.. literalinclude:: _MyDeployment.php
:language: php
:caption: MyDeployment.php

60 changes: 60 additions & 0 deletions Documentation/Installation/Surf/_MyDeployment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/** @var \TYPO3\Surf\Domain\Model\Deployment $deployment */

$node = new \TYPO3\Surf\Domain\Model\Node('my.node.com');
$node
->setHostname($node->getName())
->setOption('username', 'myuser')
->setOption('phpBinaryPathAndFilename', '/usr/local/bin/php_cli');

$application = new \TYPO3\Surf\Application\TYPO3\CMS();
$application
->setDeploymentPath('/httpdocs')
->setOption('baseUrl', 'https://my.node.com/')
->setOption('webDirectory', 'public')
->setOption('symlinkDataFolders', ['fileadmin'])
->setOption('repositoryUrl', 'file://' . dirname(__DIR__))
->setOption('keepReleases', 3)
->setOption('composerCommandPath', 'composer')
->setOption('rsyncExcludes', [
'.ddev',
'.git',
$application->getOption('webDirectory') . '/fileadmin',
'packages/**.sass'
])
->setOption(TYPO3\Surf\Task\TYPO3\CMS\FlushCachesTask::class . '[arguments]', [])
->addSymlink($application->getOption('webDirectory') . '/config/system/settings.php', '../../../../shared/Configuration/settings.php')
->addNode($node);

$deployment
->addApplication($application)
->onInitialize(
function () use ($deployment, $application) {
$deployment
->getWorkflow()
->beforeTask(
\TYPO3\Surf\Task\TYPO3\CMS\SetUpExtensionsTask::class,
\TYPO3\Surf\Task\TYPO3\CMS\CompareDatabaseTask::class,
$application
)
->beforeStage(
'transfer',
\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class,
$application
)
->afterStage('switch',
\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class,
$application
)
// CreatePackageStatesTask is done by post-autoload-dump script and can be removed
// https://github.com/TYPO3/TYPO3.CMS.BaseDistribution/blob/9.x/composer.json#L38
->removeTask(
\TYPO3\Surf\Task\TYPO3\CMS\CreatePackageStatesTask::class,
$application
)
->removeTask(
\TYPO3\Surf\Task\TYPO3\CMS\CopyConfigurationTask::class,
$application
);
}
);