typo3 surf - wiki.t3easy.de€™s typo3 surf and why this tool surf is a standalone phar / global...

28
TYPO3 Surf Get on your board ! Jan Kiesewetter @t3easy_de

Upload: dothuan

Post on 13-Apr-2018

235 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: TYPO3 Surf - wiki.t3easy.de€™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:

TYPO3 SurfGet on your board!

Jan Kiesewetter @t3easy_de

Page 2: TYPO3 Surf - wiki.t3easy.de€™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:

What is a deploymentDo 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!

Page 3: TYPO3 Surf - wiki.t3easy.de€™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:

A poor man’s deploymentTYPO3 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…

Page 4: TYPO3 Surf - wiki.t3easy.de€™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:

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?

Page 5: TYPO3 Surf - wiki.t3easy.de€™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:

Why should you surf?

Save the application knowhow in code as you already do with the business logic

Be faster!

Avoid errors

Be cool 🏄

Page 6: TYPO3 Surf - wiki.t3easy.de€™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:

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

Page 7: TYPO3 Surf - wiki.t3easy.de€™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:

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)

Page 8: TYPO3 Surf - wiki.t3easy.de€™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:

Surf commandsAvailable 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

Page 9: TYPO3 Surf - wiki.t3easy.de€™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:

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/

Page 10: TYPO3 Surf - wiki.t3easy.de€™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:

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);

Page 11: TYPO3 Surf - wiki.t3easy.de€™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:

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)

Page 12: TYPO3 Surf - wiki.t3easy.de€™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:

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

Page 13: TYPO3 Surf - wiki.t3easy.de€™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:

Structure of a Surf IIEach 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)

Page 14: TYPO3 Surf - wiki.t3easy.de€™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:

Workflow, stages and tasksA 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

Page 15: TYPO3 Surf - wiki.t3easy.de€™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:

Stage initialize

myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task\CreateDirectoriesTask

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

Page 16: TYPO3 Surf - wiki.t3easy.de€™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:

Stage package

myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task\Package\GitTask

myproject-node.tld (TYPO3 CMS) TYPO3\Surf\DefinedTask\Composer\LocalInstallTask

Page 17: TYPO3 Surf - wiki.t3easy.de€™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:

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

Page 18: TYPO3 Surf - wiki.t3easy.de€™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:

Stage update

myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task\TYPO3\CMS\SymlinkDataTask

myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task\TYPO3\CMS\CopyConfigurationTask

Page 19: TYPO3 Surf - wiki.t3easy.de€™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:

Stage migrate

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

Page 20: TYPO3 Surf - wiki.t3easy.de€™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:

Stage finalize

(No default tasks, your turn!)

Page 21: TYPO3 Surf - wiki.t3easy.de€™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:

Stage test

(No default tasks, your turn!)

Page 22: TYPO3 Surf - wiki.t3easy.de€™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:

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

Page 23: TYPO3 Surf - wiki.t3easy.de€™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:

Stage cleanup

myproject-node.tld (TYPO3 CMS) TYPO3\Surf\Task\CleanupReleasesTask

Removing releases 20170112083003

Page 24: TYPO3 Surf - wiki.t3easy.de€™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:

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

Page 25: TYPO3 Surf - wiki.t3easy.de€™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:

Trigger, trigger, trigger!composer scripts, triggered during the deployment / composer installhttps://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….

Page 26: TYPO3 Surf - wiki.t3easy.de€™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:

Example scriptsurf deploy > composer install > npm run-script > npm install, gulp, npm prune production

Page 27: TYPO3 Surf - wiki.t3easy.de€™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:

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

Page 28: TYPO3 Surf - wiki.t3easy.de€™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:

https://github.com/TYPO3/Surf

http://a-w.io/talks/2015-t3cb-deployment/

https://github.com/helhum/TYPO3-Distribution/