clean up for stand alone package

This commit is contained in:
Daniel Seifert 2024-10-30 14:46:31 +01:00
parent 1b57fc494d
commit 0c66cec2a2
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
9 changed files with 85 additions and 156 deletions

View File

@ -1,52 +1,16 @@
# Deployer recipe for OXID 6.5.x + 7.x # Deployer recipe for OXID 7.x
This project uses [Deployer](https://deployer.org/) for scripted installation This project uses [Deployer](https://deployer.org/) for scripted installation.
## Preparation The recipe can usually also be used for projects based on OXID 6.4 and 6.5.
To setup the customer repository, see [provisioning](provisioning.md). ## Usage
### Server setup See Deployer OXID recipe project for further instructions.
Install Composer. ## available tasks
Clone the repository into a separate directory (`deployer` for example) on your server and checkout this branch.
Run `composer install` in it.
Add an alias for the deployer command: `alias dep='/usr/local/php8.2/bin/php /home/XXX/deployer/vendor/bin/dep'`. Load the changed configuration.
Change project settings in the `inventory.yml`.
Create a deploy key (if it's not exist). Set it in the repository settings.
Commit changed files.
### Update Deployer
- `cd deployer`
- `composer update`
- commit changes
## Project
### Deployment
- `cd deployer`
- `dep deploy [stage]`
### Rollback
... in case of errors after successful deployment
This command set `current` directory to previous deployment:
- `dep rollback [stage]`
## Other available tasks
- dep `shop:getVersion` [stage] - show version of current OXID installation - dep `shop:getVersion` [stage] - show version of current OXID installation
- dep `shop:cloneDatabase` [stage] - dump contents from source to destination database - dep `shop:cloneDatabase` [stage] - dump contents from source to destination database
- dep `shop:runMigration` [stage] - run all database migrations - dep `shop:runMigration` [stage] - run all database migrations
- dep `setup:createDbConfig` [stage] - generate database configuration file - dep `setup:createDbConfig` [stage] - generate database configuration file
- dep `list` - list all available commands
- dep `releases` - lists all releases of the selected host
- dep `run` - run any command in the current release of the selected host (e.g. `dep run 'echo {{bin/composer}}'` for full Composer command)

View File

@ -1,5 +1,23 @@
{ {
"require-dev": { "name": "d3/oxid-deployer",
"deployer/deployer": "^7.4" "description": "Deployer recipe for OXID eShop",
"type": "library",
"license": "MIT",
"homepage": "https://d3data.de/",
"authors": [
{
"name": "D3 Data Development (Inh. Thomas Dartsch)",
"email": "info@shopmodule.com",
"homepage": "https://www.d3data.de",
"role": "Owner"
} }
],
"require": {
"deployer/deployer": "^7.4"
},
"autoload": {
"psr-4": {
"D3\\OxidDeployer\\": "."
}
}
} }

View File

@ -1,44 +0,0 @@
config:
application: my.shop.com
keep_releases: 5
repository: gitfhfac@git.d3data.de:Customers/my.shop.com.git
bin/php: /usr/local/php8.2/bin/php
bin/mysql: /usr/local/mysql/bin/mysql
bin/mysqldump: /usr/local/mysql/bin/mysqldump
# bin/composer: /usr/local/php8.1/bin/php /home/phfhcwoc/bin/composer.phar # optional for custom composer version
.base: &base
local: true
deploy_path: /home/XXX/{{application}}_{{alias}}
db_conf_path: /home/XXX/dbConf/.{{application}}_{{alias}}.cnf # optional for database actions
shared_files:
- .htaccess
- .htpasswd
- .env # otherwise source/config.inc.php
shared_dirs:
- source/sitemaps
- source/export
- source/log
- source/import
- source/out/downloads
- source/out/media
- source/out/pictures
copy_dirs:
- var
hosts:
production:
<<: *base
branch: rel_7.0.x
db_name: myProdDatabase # optional for database actions
labels:
role: production # production | stage | development
development:
<<: *base
branch: dev_7.1.x
db_name: myDevDatabase # optional for database actions
keep_releases: 1
composer_options: --verbose --prefer-dist --no-progress --no-interaction # without no-dev option
labels:
role: development

View File

@ -1,19 +0,0 @@
# Provisioning
## initial
- checkout the customer repository
- `git remote add deployment gitfhfac@git.d3data.de:D3Private/deployerRecipes.git && git remote set-url --push deployment DONTPUSH`
- `git fetch deployment`
- `git switch -c deployment deployment/rel_OXID_7.x`
checkout remote branch and rename it to `deployment`
- `git push origin deployment`
- `git remote rm deployment`
## update
- checkout the customer repository
- `git checkout deployment && git pull origin deployment`
- `git remote add deployment gitfhfac@git.d3data.de:D3Private/deployerRecipes.git && git remote set-url --push deployment DONTPUSH`
- `git fetch deployment`
- `git merge deployment/rel_OXID_7.x`
- `git push origin deployment`
- `git remote rm deployment`

8
recipe/deployTasks.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace Deployer;
desc('Oxid related tasks');
task('deploy:d3OxidTasks', [
'deploy:clear_paths'
]);

6
recipe/hooks.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Deployer;
after('deploy:failed', 'deploy:unlock');
after('deploy:vendors', 'deploy:d3OxidTasks');

10
recipe/oxid.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace Deployer;
require_once __DIR__.'/../../../deployer/deployer/recipe/composer.php';
require_once __DIR__.'/hooks.php';
require_once __DIR__.'/deployTasks.php';
require_once __DIR__.'/setupTasks.php';
require_once __DIR__.'/shopTasks.php';

33
recipe/setupTasks.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace Deployer;
desc('create database coniguration file');
task('setup:createDbConfig', function () {
try {
if (!has('db_conf_path') || !strlen(get('db_conf_path'))) {
throw new \RuntimeException('missing db_conf_path option, task stopped');
}
if (!test('[ -d $(dirname "{{db_conf_path}}") ]')) {
run('mkdir -p $(dirname "{{db_conf_path}}")');
if (!test('[ -d $(dirname "{{db_conf_path}}") ]')) {
throw new \RuntimeException('unable to create configured path {{db_conf_path}}, task stopped');
}
}
if (!test("[ -f {{db_conf_path}} ]")) {
run("touch {{db_conf_path}}");
}
if (test("[ -f {{db_conf_path}} ]")) {
$db_host = ask('database host', 'localhost');
$db_port = ask('database port', '3306');
$db_user = ask('database user');
$db_pass = askHiddenResponse('database password');
run('printf "[mysql]\nuser='.$db_user.'\npassword=\"'.$db_pass.'\"\nhost='.$db_host.'\nport='.$db_port.'\n\n[mysqldump]\nuser='.$db_user.'\npassword=\"'.$db_pass.'\"\nhost='.$db_host.'\nport='.$db_port.'" > {{db_conf_path}}');
info('config successful created');
} else {
throw new \RuntimeException('can not create {{db_conf_path}}, task stopped');
}
} catch(\RuntimeException $e) {
warning($e->getMessage());
}
});

View File

@ -1,24 +1,7 @@
<?php <?php
namespace Deployer; namespace Deployer;
require 'recipe/composer.php';
// Setup
import(__DIR__. '/inventory.yml');
// Hooks
after('deploy:failed', 'deploy:unlock');
after('deploy:vendors', 'deploy:d3OxidTasks');
/// Tasks
desc('Oxid related tasks');
task('deploy:d3OxidTasks', [
'deploy:clear_paths'
]);
desc('run all database migrations'); desc('run all database migrations');
task('shop:runMigration', [ task('shop:runMigration', [
'shop:setShopsOffline', 'shop:setShopsOffline',
@ -65,36 +48,6 @@ task('shop:setShopsOnline', function() {
} }
}); });
desc('create database coniguration file');
task('setup:createDbConfig', function () {
try {
if (!has('db_conf_path') || !strlen(get('db_conf_path'))) {
throw new \RuntimeException('missing db_conf_path option, task stopped');
}
if (!test('[ -d $(dirname "{{db_conf_path}}") ]')) {
run('mkdir -p $(dirname "{{db_conf_path}}")');
if (!test('[ -d $(dirname "{{db_conf_path}}") ]')) {
throw new \RuntimeException('unable to create configured path {{db_conf_path}}, task stopped');
}
}
if (!test("[ -f {{db_conf_path}} ]")) {
run("touch {{db_conf_path}}");
}
if (test("[ -f {{db_conf_path}} ]")) {
$db_host = ask('database host', 'localhost');
$db_port = ask('database port', '3306');
$db_user = ask('database user');
$db_pass = askHiddenResponse('database password');
run('printf "[mysql]\nuser='.$db_user.'\npassword=\"'.$db_pass.'\"\nhost='.$db_host.'\nport='.$db_port.'\n\n[mysqldump]\nuser='.$db_user.'\npassword=\"'.$db_pass.'\"\nhost='.$db_host.'\nport='.$db_port.'" > {{db_conf_path}}');
info('config successful created');
} else {
throw new \RuntimeException('can not create {{db_conf_path}}, task stopped');
}
} catch(\RuntimeException $e) {
warning($e->getMessage());
}
});
desc('show version of current OXID installation'); desc('show version of current OXID installation');
task('shop:getVersion', function () { task('shop:getVersion', function () {
if (test("[ -f {{current_path}}/composer.lock ]")) { if (test("[ -f {{current_path}}/composer.lock ]")) {