Skip to content

Commit 60f97b9

Browse files
author
Matthias Walter
committedFeb 3, 2017
[TASK] initial skeleton
1 parent d66777c commit 60f97b9

9 files changed

+258
-0
lines changed
 

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
config/local.php
3+
vendor
4+
shop

‎.ssh/config

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# web01
2+
Host web01
3+
User admin
4+
Hostname __ADD_HOSTNAME__
5+
IdentityFile ~/.ssh/__ADD_NAMESPACE__/id_rsa
6+
7+
# admin01
8+
Host admin01
9+
User admin
10+
Hostname __ADD_HOSTNAME__
11+
IdentityFile ~/.ssh/__ADD_NAMESPACE__/id_rsa
12+
13+
# db01
14+
Host db01
15+
User admin
16+
Hostname __ADD_HOSTNAME__
17+
IdentityFile ~/.ssh/__ADD_NAMESPACE__/id_rsa
18+
19+
# staging
20+
Host staging
21+
User admin
22+
Hostname __ADD_HOSTNAME__
23+
IdentityFile ~/.ssh/__ADD_NAMESPACE__/id_rsa

‎LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MIT License
22

3+
Copyright (c) 2017 netz98
34
Copyright (c) 2017 Matthias Walter
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy

‎RoboFile.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
/**
4+
* This is project's console commands configuration for Robo task runner.
5+
*
6+
* @see http://robo.li/
7+
*/
8+
class RoboFile extends \Mwltr\MageDeploy2\Robo\RoboFile
9+
{
10+
11+
}

‎config/local.php.dist

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 1999-2016 netz98 GmbH (http://www.netz98.de)
4+
*
5+
* @see LICENSE
6+
*/
7+
8+
namespace Deployer;
9+
10+
use N98\Deployer\RoleManager;
11+
12+
$local = localServer('local');
13+
$local->user('__ADD_YOUR_LOCAL_USERNAME__');
14+
$local->set('deploy_path', '__ADD_DEPLOY_PATH__');
15+
$local->stage('dev');
16+
17+
$local->set('config-store-env', '__SET_YOUR_CONFIG_STORE_ENV__');
18+
$local->set('webserver-user', '__SET_YOUR_LOCAL_USER__');
19+
$local->set('webserver-group', '__SET_YOUR_LOCAL_GROUP__');
20+
$local->set('bin/n98_magerun2', 'n98-magerun2.phar');
21+
22+
RoleManager::addServerToRoles('local', ['web', 'db']);

‎config/production.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 1999-2016 netz98 GmbH (http://www.netz98.de)
4+
*
5+
* @see LICENSE
6+
*/
7+
8+
namespace Deployer;
9+
10+
use N98\Deployer\RoleManager;
11+
12+
$deployPath = '/var/www/__ADD_DEPLOY_PATH__';
13+
$sshConfigFile = '.ssh/config';
14+
15+
// Frontend Web Server 01
16+
$production = server('web01', 'web01');
17+
$production->user('admin');
18+
$production->configFile($sshConfigFile);
19+
$production->set('deploy_path', $deployPath);
20+
$production->stage('production');
21+
$production->set('config-store-env', 'production');
22+
23+
// Admin Server running crons, sftp and in the future the admin-panel
24+
$production = server('admin01', 'admin01');
25+
$production->user('admin');
26+
$production->configFile($sshConfigFile);
27+
$production->set('deploy_path', $deployPath);
28+
$production->stage('production');
29+
$production->set('config-store-env', 'production');
30+
31+
RoleManager::addServerToRoles('web01', ['web', 'production']);
32+
RoleManager::addServerToRoles('admin01', ['web', 'db', 'production']);
33+

‎config/staging.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 1999-2016 netz98 GmbH (http://www.netz98.de)
4+
*
5+
* @see LICENSE
6+
*/
7+
8+
namespace Deployer;
9+
10+
use N98\Deployer\RoleManager;
11+
12+
$deployPath = '/var/www/__ADD_DEPLOY_PATH__';
13+
14+
$staging = server('staging', 'staging');
15+
$staging->user('admin');
16+
$staging->configFile('.ssh/config');
17+
$staging->set('deploy_path', $deployPath);
18+
$staging->stage('staging');
19+
$staging->set('config-store-env', 'production');
20+
21+
RoleManager::addServerToRoles('staging', ['web', 'db', 'staging']);

‎deploy.php

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 1999-2017 netz98 GmbH (http://www.netz98.de)
4+
*
5+
* @see LICENSE
6+
*/
7+
namespace Deployer;
8+
9+
use N98\Deployer\DeployFile\N98Magento2DeployFile;
10+
use N98\Deployer\Task\BuildTasks;
11+
use N98\Deployer\Task\CleanupTasks;
12+
use N98\Deployer\Task\DeployTasks;
13+
use N98\Deployer\Task\MagentoTasks;
14+
use N98\Deployer\Task\SystemTasks;
15+
16+
require 'recipe/common.php';
17+
18+
N98Magento2DeployFile::configuration();
19+
20+
/**
21+
* CONFIGURATION
22+
*/
23+
\Deployer\set('webserver-user', 'www-data');
24+
\Deployer\set('webserver-group', 'www-data');
25+
26+
\Deployer\set('phpfpm_service', 'php7.0-fpm');
27+
\Deployer\set('nginx_service', 'nginx');
28+
29+
/**
30+
* SERVERS
31+
*/
32+
$configLocal = __DIR__ . '/config/local.php';
33+
if (is_file($configLocal)) {
34+
require_once $configLocal;
35+
}
36+
require_once __DIR__ . '/config/staging.php';
37+
require_once __DIR__ . '/config/production.php';
38+
39+
N98Magento2DeployFile::tasks();
40+
41+
/**
42+
* DEPLOYMENT PIPELINE
43+
*/
44+
desc('Deploy Project');
45+
task(
46+
'deploy', [
47+
'deploy:initialize',
48+
'deploy:prepare',
49+
'deploy:release',
50+
BuildTasks::TASK_UPLOAD_ARTIFACTS,
51+
BuildTasks::TASK_FIX_FILE_OWNERSHIP,
52+
'deploy:shared', // link shared dirs / files
53+
MagentoTasks::TASK_SYMLINKS_ENABLE,
54+
'deploy:symlink', // ACTIVATE RELEASE
55+
MagentoTasks::TASK_MAINTENANCE_MODE_ENABLE,
56+
MagentoTasks::TASK_CACHE_DISABLE,
57+
MagentoTasks::TASK_SETUP_UPGRADE,
58+
MagentoTasks::TASK_CONFIG_DATA_IMPORT,
59+
MagentoTasks::TASK_CMS_DATA_IMPORT,
60+
MagentoTasks::TASK_CACHE_ENABLE,
61+
BuildTasks::TASK_FIX_FILE_OWNERSHIP,
62+
'deploy:clear_paths',
63+
MagentoTasks::TASK_MAINTENANCE_MODE_DISABLE,
64+
SystemTasks::TASK_PHP_FPM_RESTART,
65+
// SystemTasks::TASK_NGINX_RESTART,
66+
CleanupTasks::TASK_CLEANUP,
67+
'success',
68+
]
69+
);
70+
71+
after('deploy:prepare', BuildTasks::TASK_SHARED_DIRS_GENERATE);
72+
73+
// Rollback in case of failure
74+
onFailure('deploy', DeployTasks::TASK_ROLLBACK);
75+
76+
// @todo we might need to think about downgrading db versions that may have been upgrade during setup_upgrade
77+
// after(DeployTasks::TASK_ROLLBACK, MagentoTasks::TASK_SETUP_DOWNGRADE);

‎magedeploy2.php

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
return [
4+
'env' => [
5+
'git_bin' => '/usr/local/bin/git',
6+
'php_bin' => '/usr/local/bin/php',
7+
'tar_bin' => '/usr/local/bin/gtar',
8+
'composer_bin' => '/usr/local/bin/composer.phar',
9+
'deployer_bin' => './vendor/bin/dep',
10+
],
11+
'deploy' => [
12+
'git_url' => '__SET_GIT_URL__', // @todo set git url
13+
'git_dir' => 'shop',
14+
'magento_dir' => 'shop/src', // @todo set git repo sub-dir if necessary
15+
'themes' => [ // @todo adjust to your projects needs
16+
'Magento/luma' => [
17+
'de_DE',
18+
],
19+
'Magento/backend' => [
20+
'de_DE',
21+
'en_US',
22+
],
23+
],
24+
'assets' => [
25+
'var_di.tar.gz' => ['dir' => 'src/var/di'],
26+
'var_generation.tar.gz' => ['dir' => 'src/var/generation'],
27+
'pub_static.tar.gz' => ['dir' => 'src/pub/static'],
28+
'shop.tar.gz' => [
29+
'dir' => 'src',
30+
'options' => [
31+
'--exclude-vcs',
32+
// '--exclude-from=artifact.ignore',
33+
'--checkpoint=5000',
34+
],
35+
],
36+
],
37+
'clean_dirs' => [
38+
'var/cache',
39+
'var/di',
40+
'var/generation',
41+
],
42+
],
43+
'magento' => [
44+
'db' => [
45+
'admin-email' => 'admin@localhost',
46+
'admin-firstname' => 'Admin',
47+
'admin-lastname' => 'Admin',
48+
'admin-password' => 'admin123',
49+
'admin-user' => 'admin',
50+
'backend-frontname' => 'admin',
51+
'base-url' => 'http://magedeploy2_dev',
52+
'base-url-secure' => 'https://magedeploy2_dev',
53+
'currency' => 'EUR',
54+
'db-host' => '127.0.0.1', // @todo set your database configuration
55+
'db-name' => 'magedeploy2_dev',
56+
'db-password' => '',
57+
'db-user' => 'root',
58+
'language' => 'en_US',
59+
'session-save' => 'files',
60+
'timezone' => 'Europe/Berlin',
61+
'use-rewrites' => '1',
62+
'use-secure' => '0',
63+
'use-secure-admin' => '0',
64+
],
65+
],
66+
];

0 commit comments

Comments
 (0)
Please sign in to comment.