typo3 surf
play

TYPO3 Surf Get on your board! Jan Kiesewetter @t3easy_de What is a - PowerPoint PPT Presentation

TYPO3 Surf Get on your board! Jan Kiesewetter @t3easy_de What is a deployment Do recurring tasks (manual or automatically) to install/ update an application in an predetermined sequence Download external dependencies Generate assets Upload


  1. TYPO3 Surf Get on your board! Jan Kiesewetter @t3easy_de

  2. What is a deployment Do recurring tasks (manual or automatically) to install/ update an application in an predetermined sequence Download external dependencies Generate assets Upload data (For me) Not an provisioning, use Ansible/Chef/Puppet for that!

  3. A poor man’s deployment TYPO3 Extension git archive -o ${PWD##*/}.zip HEAD add necessary non git files (e.g. vendor, node_modules) to zip Login into backend, open extension manager upload extensions in the right order 🤕😲 Clear cache Test frontend TYPO3 site get.typo3.org / composer install Extension Manager install distribution distribution requires TER ext…

  4. Automation | I/O your deployment Run the same tasks in the same order on every involved system, e.g. production and staging server Get response Role back if something breaks to avoid dirty environments Surf, the end of the rainbow?

  5. Why should you surf? Save the application knowhow in code as you already do with the business logic Be faster! Avoid errors Be cool 🏅

  6. What’s TYPO3 Surf and why this tool Surf is a standalone phar / global composer package since v2 (still beta) Not a Flow Package anymore! (Und alle so: YEAH!) It comes with ready2use workflows to deploy TYPO3 CMS, Flow, Neos Applications It’s part of TYPO3, developed and used by core members It’s written in PHP , every PHP developer can read the code and understand what it is doing and how to write own applications/tasks It’s extendable and usable for almost every application It can deploy multiple applications to multiple nodes with one deployment

  7. Surf needs… A git repository for each application, at least $repositoryUrl = 'file://' . dirname(__DIR__); 
 for a single application php, (composer), git, rsync (and some binaries on the node)

  8. Surf commands Available commands: deploy describe help Displays help for a command list Lists commands migrate show simulate Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

  9. Where to put the deployments Structure inside of your application project .surf ProjectXY.php <- This is the deployment recipe ProjectXY <- Folder for files that belongs to the recipe Configuration what ever web/index.php <- e.g. the TYPO3 index.php composer.json composer.lock If you deploy multiple applications at once, you can save the surf configuration inside the main app or in a separate repository Global deployments ~/.surf/deployments/

  10. The workspaces Folder on the system running the surf command ~/.surf/workspace + name of the deployment + name of the app ~/.surf/workspace/MySite/TYPO3 CMS ~/.surf/workspace/Customer/TYPO3 CMS C:\Users\User\AppData\Local\Surf\MySite\TYPO3 CMS Base path can be changed throw env SURF_WORKSPACE IT IS NOT TIDIED BETWEEN DEPLOYMENTS!!! If you don’t commit your composer.lock it will be generated there and used for the next composer install $application->setOption('TYPO3\\Surf\\Task\\Package\\GitTask[hardClean]', true);

  11. Serve your Surf || Structure inside the remote deploymentPath cache transfer (rsync target) releases 20170105185908 20170105214101 20170105223334 20170304112206 current -> ./20170105223334 previous -> ./20170105214101 next -> ./20170304112206 (just during deployment) shared Data fileadmin uploads Point your production domain to $deploymentPath/releases/current/web (Point your smoke test domain to $deploymentPath/releases/next/web) (Point your previous domain to $deploymentPath/releases/previous/web)

  12. Structure of a Surf I A deployment has One workflow The workflow hast multiple multiple tasks One release identifier „%Y%m%d%H%M%S“ One workspace base path Multiple options, e.g. initialDeployment used by TYPO3 CMS One or more applications

  13. Structure of a Surf II Each application has: One deployment path One context (depending on the application) One transferMethod, rsync by default, but also git The transferMethod is significant for where are tasks executed, „local“ or remote! Multiple options (inherited from Deployment) used are: packageMethod, transferMethod, updateMethod repositoryUrl branch TYPO3 CMS has: context, scriptFileName, webDirectory, rsyncExcludes => [], initialDeployment TYPO3\\Surf\\Task\\Generic\\CreateDirectoriesTask[directories], TYPO3\\Surf\\Task\\Generic\ \CreateSymlinksTask[symlinks] One or more nodes (server, targets, hostings) each has hostname Multiple options (inherited from the deployment and the application)

  14. Workflow, stages and tasks A workflow can have multiple stages, the SimpleWorkflow has the predefined stages: initialize package transfer update migrate finalize test switch cleanup A task belongs to one stage An application adds tasks to the workflow

  15. Stage initialize myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \CreateDirectoriesTask myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \Generic\CreateDirectoriesTask

  16. Stage package myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \Package\GitTask myproject-node.tld (TYPO3 CMS) TYPO3\Surf \DefinedTask\Composer\LocalInstallTask

  17. Stage transfer myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \Transfer\RsyncTask myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \Generic\CreateSymlinksTask myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \TYPO3\CMS\CreatePackageStatesTask

  18. Stage update myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \TYPO3\CMS\SymlinkDataTask myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \TYPO3\CMS\CopyConfigurationTask

  19. Stage migrate myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \TYPO3\CMS\SetUpExtensionsTask

  20. Stage finalize (No default tasks, your turn!)

  21. Stage test (No default tasks, your turn!)

  22. Stage switch myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \SymlinkReleaseTask Node "myproject-node.tld" is live! myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \TYPO3\CMS\FlushCachesTask

  23. Stage cleanup myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task \CleanupReleasesTask Removing releases 20170112083003

  24. How to hook in? Add tasks to the workflow from inside your deployment configuration You can add own tasks before/after other tasks or to a stage addTaskToStage, afterTask, beforeTask, beforeStage, afterStage Develop a composer package that saves some global available applications and tasks for you Maybe a Magento or Piwik Application with tasks to deploy them streamlined with TYPO3

  25. Trigger, trigger, trigger! composer scripts, triggered during the deployment / composer install 
 https://getcomposer.org/doc/articles/scripts.md You can use something like „npm run-script build“ as composer post-install-cmd 
 https://docs.npmjs.com/misc/scripts You can use gulp as npm build script… gulp tasks….

  26. Example script surf deploy > composer install > npm run-script > npm install, gulp, npm prune production

  27. Database?! Database is migrated with typo3_console during the deployment by default 
 (default: *.add,*.change, can be changed with $options['databaseCompareMode']) Database is NOT dumped before migration… because?! Backup a large DB will harm the live app A rollback of a DB is hard, because it could have been changed on life after the deployment (new pages/CEs) You can add a dump task to you workflow that fits your needs

  28. https://github.com/TYPO3/Surf http://a-w.io/talks/2015-t3cb-deployment/ https://github.com/helhum/TYPO3-Distribution/

Recommend


More recommend