Are you interested in automating TYPO3 deployment effectively? This article explores deployment standards of TYPO3, employing tools such as Bitbucket CI/CD, deployer, code review, frontend build, docker/ddev, and setting up development, staging, and production environments. Discover the recommended practices for TYPO3 v12 and DevOps in this informative article.
Are you still manually deploying your TYPO3 projects using old-fashioned methods like SFTP/SSH? Well, it's time to leave those behind in 2023! Say goodbye to manual TYPO3 deployers and complicated SSH commands. Instead, let's make your TYPO3 deployment completely automated using TYPO3 Bitbucket CI/CD. This means you can save time and effort by automating the deployment process, making it simpler and more efficient. So, why not embrace this modern approach and make your TYPO3 development and deployment a breeze in 2023?
If you are also interested in TYPO3 Gitlab, I highly recommend reading our famous article TYPO3 Gitlab CI/CD Auto Deployment (2022).
Attention:
Are you ready for the TYPO3 + Bitbucket + CI/CD journey? This article provides a TYPO3 v12 sample, but if you're working with older TYPO3 versions, you'll need to make some adjustments, particularly regarding the bit architecture.
Now, let's dive into the exciting world of TYPO3 + Bitbucket + CI/CD! It's time to streamline your TYPO3 development and deployment process. Let's go!
What is TYPO3 CI/CD?
Say goodbye to the days of manual deployment and complex command-based workflows! With TYPO3 CI/CD (Continuous Integration and Continuous Development), you can automate the deployment of your TYPO3 project.
The magic happens through your Git repository. By simply using commands like git push or git tag, you can trigger the automatic deployment of your latest code to the staging or production server.
But that's not all! TYPO3 CI/CD also offers a nifty feature: code testing before deployment. This allows you to ensure that your TYPO3 code meets the highest quality standards and gives you greater control over its overall quality.
Embrace TYPO3 CI/CD and enjoy the ease of automated deployment and the peace of mind that comes with code testing. It's time to simplify your TYPO3 development process and take it to the next level!
Steps to Auto Deployment TYPO3
Auto-deploying TYPO3 using Bitbucket CI/CD is as easy as 1-2-3:
- Make code changes and commit them using `git push`.
- Start the TYPO3 Bitbucket pipeline runners.
- Sit back and relax! Your new code will be automatically deployed to the server.
Just run `git push`, and your deployment is taken care of seamlessly. It's that simple and cool! Enjoy the convenience of automating TYPO3 deployment with Bitbucket CI/CD.
TYPO3 Bitbucket Pipedrives
Exactly what do we want to achieve? Take a look at the below screencast, we want to achive these 4 things.
1. Automatic Code Review (Example PHP)
2. Build TYPO3 (Using Composer Install)
3. Build Frontend Assets (Using Nodejs/Yarnjs Install)
4. Auto-Deploy to Servers (Staging or Production)
List of Technologies for TYPO3 Deployment
You will need to start with modern technologies to develop and deploy TYPO3 projects efficiently..
- Operating System (recommended UNIX based)
- Docker >= 18.x
- Docker Composer >= 3.x
- DDEV
- Composer >= 2.x
- PHP >= 7.4.x
- Deployer >= 6.x
- PHPStan and PHP-CS-Fixer
- Nodejs/Webpack (optional)
The Architecture of TYPO3 Bitbucket CI/CD
Using the TYPO3 v12 setup, Please consider below minimal Git TYPO3 architecture.
- .ddev
- config
-- sites
-- default
-- system
-- settings.php
-- additional.php
- packages
-- your-custom-package
- composer.json
- deploy.php
- bitbucket-pipelines.yml
- phpstan.neon
Understand the Basics of TYPO3 DevOps
The essential information instructions are for understanding local development and TYPO3 DevOps setup.
build/deploy.php
Contains PHP Deployer recipe, It’s just a simple PHP script - I’m sure you will easily understand.
config/system
You can configure TYPO3 installation based on your server needs, like Local or Production.
config/system
You can configure TYPO3 sites.
packages/*
Add your custom-developed TYPO3 extensions e.g., your template extension.
image: php:8.1
definitions:
steps:
- step: &code-analysis
name: PHPStan
caches:
- composer
script:
- composer install --ignore-platform-reqs --no-progress --no-interaction
- if [ -e vendor/bin/phpstan ]; then php -d memory_limit=2G vendor/bin/phpstan analyse; fi
- step: &build
name: Composer
caches:
- composer
artifacts:
- public/**
- packages/**
- config/**
- vendor/**
script:
- composer install --ignore-platform-reqs --no-dev --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader
- step: &build-frontend
name: Node.js
image: node:19.9.0-alpine3.18
caches:
- node
artifacts:
- public/**
script:
- yarn
- yarn build
- step: &deploy
name: Deploy
caches:
- composer
script:
- composer global require deployer/deployer:^6.3 deployer/recipes --dev --no-progress --no-interaction
- "`composer global config bin-dir --absolute`/dep --file=./deploy.php deploy -vv --hosts=${TARGET_HOSTS}"
pipelines:
branches:
main:
- parallel:
steps:
- step:
<<: *code-analysis
- step:
<<: *build
- step:
<<: *build-frontend
- step:
<<: *deploy
deployment: Production
<?php declare(strict_types=1);
namespace Deployer;
require 'recipe/common.php';
require 'recipe/rsync.php';
function env(string $name): string|array
{
$value = getenv($name);
if ($value === false) {
throw new \RuntimeException(\sprintf(
'Environment variable \'%s\' missing.',
$name,
));
}
return $value;
}
host('main')
->hostname(env('SSH_HOST'))
->user(env('SSH_USER'))
->set('deploy_path', env('DEPLOY_PATH'))
->set('writable_mode', 'chmod')
->set('keep_releases', '3');
// Prepare Directory Structure
$sharedDirectories = [
'public/fileadmin',
//'public/typo3temp',
//'var',
];
set('shared_dirs', $sharedDirectories);
$sharedFiles = [
'.env',
'public/.htaccess',
];
set('shared_files', $sharedFiles);
$writeableDirectories = [
'public/fileadmin',
'public/typo3temp',
'var',
];
set('writable_dirs', $writeableDirectories);
$exclude = [
'.ddev',
'deploy.php',
'package.json',
'package-lock.json',
'.env',
'var/',
'public/fileadmin/',
'public/typo3temp/'
];
// Ready for Rsync
set('rsync', [
'exclude' => array_merge($sharedDirectories, $sharedFiles, $exclude),
'exclude-file' => false,
'include' => [],
'include-file' => false,
'filter' => [],
'filter-file' => false,
'filter-perdir' => false,
'flags' => 'avz',
'options' => ['delete'],
'timeout' => 300
]);
set('rsync_src', '.');
// Execute TYPO3 CLIs
task('typo3:extension:setup', function() {
cd('{{release_path}}');
run('vendor/bin/typo3 extension:setup');
});
task('typo3:database:updateschema', function() {
cd('{{release_path}}');
run('vendor/bin/typo3 database:updateschema');
});
task('typo3:cache:flush', function() {
cd('{{release_path}}');
run('vendor/bin/typo3 cache:flush');
});
task('typo3:cache:warmup', function() {
cd('{{release_path}}');
run('vendor/bin/typo3 cache:warmup');
});
task('typo3:language:update', function() {
cd('{{release_path}}');
run('vendor/bin/typo3 language:update');
});
// Let's Deploy Now!
task('deploy', [
'deploy:prepare',
'deploy:lock',
'deploy:release',
'rsync:warmup',
'rsync',
'deploy:shared',
'deploy:writable',
'typo3:extension:setup',
//'typo3:database:updateschema',
'typo3:language:update',
'typo3:cache:flush',
'typo3:cache:warmup',
'deploy:symlink',
'deploy:unlock',
'cleanup',
'success'
]);
// unlock after failure
after('deploy:failed', 'deploy:unlock');
{
"name": "typo3/bitbucket-project-template",
"description" : "TYPO3 CMS Distribution - Bitbucket Project Template",
"license": "GPL-2.0-or-later",
"type": "project",
"config": {
"allow-plugins": {
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true,
"helhum/dotenv-connector": true,
"phpstan/extension-installer": true
},
"platform": {
"php": "8.2"
},
"sort-packages": true
},
"prefer-stable": true,
"minimum-stability": "dev",
"repositories": {
"local-packages": {
"type": "path",
"url": "packages/*"
}
},
"require": {
"helhum/dotenv-connector": "^3",
"typo3/cms-backend": "^12",
"typo3/cms-belog": "^12",
"typo3/cms-beuser": "^12",
"typo3/cms-core": "^12",
"typo3/cms-dashboard": "^12",
"typo3/cms-extbase": "^12",
"typo3/cms-extensionmanager": "^12",
"typo3/cms-felogin": "^12",
"typo3/cms-filelist": "^12",
"typo3/cms-fluid": "^12",
"typo3/cms-fluid-styled-content": "^12",
"typo3/cms-form": "^12",
"typo3/cms-frontend": "^12",
"typo3/cms-info": "^12",
"typo3/cms-install": "^12",
"typo3/cms-lowlevel": "^12",
"typo3/cms-rte-ckeditor": "^12",
"typo3/cms-seo": "^12",
"typo3/cms-setup": "^12",
"typo3/cms-sys-note": "^12",
"typo3/cms-t3editor": "^12",
"typo3/cms-tstemplate": "^12",
"typo3/cms-viewpage": "^12"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.13.0",
"helmich/typo3-typoscript-lint": "^3.0.0",
"php-coveralls/php-coveralls": "^2.5.3",
"phpunit/phpunit": "^9.5.26",
"saschaegerer/phpstan-typo3": "^1.8",
"seld/jsonlint": "^1.9.0",
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/yaml": "^5.4 || ^6.1",
"typo3/cms-fluid-styled-content": "^11.5.4 || ^12.0",
"typo3/coding-standards": "^0.5.5"
}
}
TYPO3_TRUSTED_HOSTS=.*.*
TYPO3_CONTEXT=Production
TYPO3_DB_DATABASE=
TYPO3_DB_USERNAME=
TYPO3_DB_PASSWORD=
TYPO3_DB_HOST=
TYPO3_DB_PORT=3306
TYPO3_DB_DRIVER=mysqli
SSH_HOST=
SSH_USER=
DEPLOY_PATH=
That’s it! You are ready to launch your first TYPO3 Bitbucket CI/CD - Just run `git push`
Helpful Links for TYPO3 DevOps
You may also like to read more articles on the TYPO3 deployment as below.
- TYPO3 Gitlab CI/CD Auto Deployment (2022)
- How to Automise Your TYPO3 Deployment (with PHP Deployer)
- How to Configure PHP Deployer in TYPO3?
- 8 Best TYPO3 Docker Development Approaches
- How to Auto-Release TYPO3 Extension with Github?
- 8 Ways to Publish Your TER TYPO3 Extensions
- The Best Guide to TYPO3 Composer
Wrapping-up!
Thanks for reading my blog. I hope you like it and found it helpful.
I highly recommend trying TYPO3 CI/CD auto-deploy, especially if you're still using traditional manual deployment methods. Embracing the challenge and transitioning to automated deployment aligns perfectly with the goals and vision for 2023. If you encounter any obstacles along the way, don't hesitate to reach out. I'm here to assist you and provide support.
If you're already excelling in TYPO3 DevOps, that's fantastic! I'm curious to know your preferred method of TYPO3 deployment. Your feedback and experiences would be greatly appreciated. Feel free to share your thoughts in the comment box below.
Have a Happy TYPO3 Deploying!
Thanks for breaking down the TYPO3 Bitbucket CI/CD setup into simple steps. It helped me understand everything perfectly!