-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Ph3nol/dev
CustomService + CapistranoService + Fixes/Improvements
- Loading branch information
Showing
25 changed files
with
295 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Docker Arch - Capistrano Project | ||
services: | ||
# Nginx Container | ||
- type: nginx | ||
path: ../app | ||
host: localhost | ||
# Capistrano | ||
- type: capistrano | ||
options: | ||
version: "3.9.1" | ||
zsh: true | ||
# dotfiles: true # Use this instead of this example volumes to fake SSH key access | ||
container: | ||
volumes: | ||
- "../docker:/root/.ssh:ro" | ||
working_dir: /apps/nginx | ||
# Custom SSH image (deploy server destination) | ||
- type: custom | ||
options: | ||
image: ncc0706/alpine-sshd | ||
package_manager: apk | ||
container: | ||
volumes: | ||
- "../docker/authorized_keys:/root/.ssh/authorized_keys:ro" | ||
packages: | ||
- git | ||
commands: | ||
- "mkdir ~/.ssh" | ||
- "echo 'Host *' >> ~/.ssh/config" | ||
- "echo ' ForwardAgent yes' >> ~/.ssh/config" | ||
working_dir: /var/www/docker-arch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app*/log | ||
app*/.bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "capistrano/setup" | ||
require "capistrano/deploy" | ||
|
||
require "capistrano/scm/git" | ||
install_plugin Capistrano::SCM::Git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
lock "3.9.1" | ||
|
||
set :application, "docker-arch-app" | ||
set :repo_url, 'https://github.com/Ph3nol/Docker-Arch.git' | ||
set :keep_releases, 1 | ||
|
||
set :ssh_options, { :forward_agent => true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set :stage, :staging | ||
|
||
server 'custom', user: 'root', roles: %w{web app}, port: 22 | ||
|
||
set :deploy_to, '/var/www/docker-arch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Capistrano</title> | ||
</head> | ||
<body> | ||
<h1>Capistrano</h1> | ||
|
||
<p> | ||
This is an example app.<br> | ||
Just go to Capistrano instance shell (from <i>.docker-arch/do shell</i> for example) and run | ||
<i>cap example deploy</i> to deploy fake application (Docker-Arch Git project) | ||
to fake destination server instance through SSH. | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+rrm4Vz2ue7oVcmaYuqDWOR+jWqIRJv/JMEIYkUV1V7Agu8zrqd5FUG931HeqnYVeSMOMSD9tYQTQkbFks1OC+leUU8enlnR/ZYqBkROQ03PMyJfNqjGvOTx+cKXkzyCHt7SXHwnsabvD81/5tpN54CmdvWScXf+BtrNcbJBxNDw0pxK/SxBmwBdEJYuhjRW7L1uQkLM2LQ515iAk4BsX+XzlnaYDI5Ul099gpa+17bmDKSdETRM/AhetUWflXZjmchwoVNw5S/jzRvL3QcZfq+Z/PHMiM2VxsTe7YCZSv8VSTKGFOQK1Gn7bSAQ9wm2RU4Qh3lVCv2LKd08wv1kB5WK0XxKd/yT3tXftoqPnpb98SVcyjf4M0dRYqaEZ/ZZDfojx0eLn/yK3KLFwKWUfumR0RoB+eeoY2XinyQ1u1rjc8KVHjeYON7jsvovDOSBwTgBg3IvSXo+7gRMUQAK5YI1uq3Lr3xtHvzMO+xkqr1OdaMPPlOg4ZkIOhhMM5LxWnlQK14XVtBNpEp5u3VDIKsL/o6JmlAbpx/HxFUnbrjdjPD2BUAWPiL+7obmaj7v3ZTeytawouUK3RYA685PD4gVboPnYWNU7k7oG6u/LVVw1cHmqmXbbSMZ3DdxEsgC7HT/dLJ50+2y7vC9GSPXwlCrN0TibVdfgrDDXfXeqoQ== hello@localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIJKAIBAAKCAgEAvq65uFc9rnu6FXJmmLqg1jkfo1qiESb/yTBCGJFFdVewILvM | ||
66neRVBvd9R3qp2FXkjDjEg/bWEE0JGxZLNTgvpXlFPHp5Z0f2WKgZETkNNzzMiX | ||
zaoxrzk8fnCl5M8gh7e0lx8J7Gm7w/Nf+baTeeApnb1knF3/gbazXGyQcTQ8NKcS | ||
v0sQZsAXRCWLoY0Vuy9bkJCzNi0OdeYgJOAbF/l85Z2mAyOVJdP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3OoVIqpDiP | ||
g5bPddiFU3FasAwsn3Geqdu68jlXG5u86kTNKzl8TnFwVEvtwz3UNpitAhEegSi6 | ||
CwNyEpidnmfkiw8k2TwR3y6iWvQQkvfdlYYO0Bc7EHqBrLZchFG7NQY18HA5NsD9 | ||
HyQHHQKCAQB7H3DP1YCsunRrJswLo2IKxLtgMegWHloF99DVFzFmFJntQ/PMHrAk | ||
zVeKRm71jbFKZA1WIQfPao1VwmSZ4y2OL2ty5uaYEqUVy9nvwJwekRdfMLHNg4K/ | ||
9fkhzkSSiKl8wiAFiaEwraB73pHoPj3Ogn7he6jDoGlo4bsY0pKXleakcChSIZnR | ||
AX95zycChAB5153cGRihFlhulytxSbKlFGIWPau8wctlBhNbJFADMRTG1HQLCohM | ||
CD9grQJpyIdHAhDIV7V7vbnOpbapbrQeF+pUN+Zw/eN8lruXrD/x5ac87bI5yyZX | ||
VR4tD76z70fCDFPxEJhkDRiAFoadIK3XAoIBAFlL82X3CoXSEQ9eHa1O5xY9bxFA | ||
d71FT/GwnYXZGNJrt/jNW48pGIfAa+ZZliPElzSeiIPpqytXN+4CDG96iT+jRb6X | ||
LTWVYikhuE82igiqHPnGvnhVjMsrxDNKZ8qQKHBuU9QIJh9cWnF1cNYUt2nkRHWq | ||
/BhvRidqIZ7AdDiNnQIR9Ed8GtujHIF+Wl6e5baInvDHiIYwI5l+zrNFsoMZFhIN | ||
Z/CrvPC1SC8nhaZY80N+b57ZrA4tRUXTtvfoQ4B3KcbCuIRThaapPaZPQ24X+veH | ||
9+fQVM3hhwd0MOIfJ0+zuVGo9Q+hBCeOQZnE2jH/RJGtZFLK7OBK7qKee34= | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+rrm4Vz2ue7oVcmaYuqDWOR+jWqIRJv/JMEIYkUV1V7Agu8zrqd5FUG931HeqnYVeSMOMSD9tYQTQkbFks1OC+leUU8enlnR/ZYqBkROQ03PMyJfNqjGvOTx+cKXkzyCHt7SXHwnsabvD81/5tpN54CmdvWScXf+BtrNcbJBxNDw0pxK/SxBmwBdEJYuhjRW7L1uQkLM2LQ515iAk4BsX+XzlnaYDI5Ul099gpa+17bmDKSdETRM/AhetUWflXZjmchwoVNw5S/jzRvL3QcZfq+Z/PHMiM2VxsTe7YCZSv8VSTKGFOQK1Gn7bSAQ9wm2RU4Qh3lVCv2LKd08wv1kB5WK0XxKd/yT3tXftoqPnpb98SVcyjf4M0dRYqaEZ/ZZDfojx0eLn/yK3KLFwKWUfumR0RoB+eeoY2XinyQ1u1rjc8KVHjeYON7jsvovDOSBwTgBg3IvSXo+7gRMUQAK5YI1uq3Lr3xtHvzMO+xkqr1OdaMPPlOg4ZkIOhhMM5LxWnlQK14XVtBNpEp5u3VDIKsL/o6JmlAbpx/HxFUnbrjdjPD2BUAWPiL+7obmaj7v3ZTeytawouUK3RYA685PD4gVboPnYWNU7k7oG6u/LVVw1cHmqmXbbSMZ3DdxEsgC7HT/dLJ50+2y7vC9GSPXwlCrN0TibVdfgrDDXfXeqoQ== hello@localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Docker Arch - Custom Image Project | ||
services: | ||
# SFTP Container (connect from `sftp -P 2222 docker-arch@localhost`, password: unicorn) | ||
- type: custom | ||
options: | ||
image: "atmoz/sftp:alpine" | ||
package_manager: apk | ||
container: | ||
cmd: | ||
- "docker-arch:unicorn:1001" | ||
ports: | ||
- "2222:22" |
38 changes: 38 additions & 0 deletions
38
src/Application/DockerContainer/CapistranoDockerContainer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Ph3\DockerArch\Application\DockerContainer; | ||
|
||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer; | ||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface; | ||
|
||
/** | ||
* @author Cédric Dugat <[email protected]> | ||
*/ | ||
class CapistranoDockerContainer extends DockerContainer | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPackageManager(): string | ||
{ | ||
return DockerContainerInterface::PACKAGE_MANAGER_TYPE_APK; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute(): void | ||
{ | ||
$this->setFrom('ruby:2-alpine3.6'); | ||
|
||
$service = $this->getService(); | ||
|
||
$this->applyDotfiles(); | ||
$this->applyShellConfiguration(); | ||
$this->setWorkingDir('/apps'); | ||
|
||
$this | ||
->addCommand('gem install capistrano --version='.$service->getOptions()['version']) | ||
->addCommand('gem install capistrano-scm-local'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Ph3\DockerArch\Application\DockerContainer; | ||
|
||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer; | ||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface; | ||
|
||
/** | ||
* @author Cédric Dugat <[email protected]> | ||
*/ | ||
class CustomDockerContainer extends DockerContainer | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPackageManager(): string | ||
{ | ||
return $this->getService()->getOptions()['package_manager']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute(): void | ||
{ | ||
$this->setFrom($this->getService()->getOptions()['image']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Ph3\DockerArch\Application\Service; | ||
|
||
use Ph3\DockerArch\Domain\Service\Model\AbstractService; | ||
use Symfony\Component\OptionsResolver\Options; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @author Cédric Dugat <[email protected]> | ||
*/ | ||
class CapistranoService extends AbstractService | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getOptionsResolver(): Options | ||
{ | ||
$resolver = new OptionsResolver(); | ||
$resolver->setRequired(['version']); | ||
$resolver->setDefaults([ | ||
'version' => '3.9.1', | ||
'zsh' => true, | ||
'dotfiles' => true, | ||
]); | ||
|
||
return $resolver; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isCliOnly(): bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Ph3\DockerArch\Application\Service; | ||
|
||
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface; | ||
use Ph3\DockerArch\Domain\Service\Model\AbstractService; | ||
use Symfony\Component\OptionsResolver\Options; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @author Cédric Dugat <[email protected]> | ||
*/ | ||
class CustomService extends AbstractService | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getOptionsResolver(): Options | ||
{ | ||
$resolver = new OptionsResolver(); | ||
$resolver->setRequired(['image', 'package_manager']); | ||
$resolver->setAllowedValues('package_manager', [ | ||
DockerContainerInterface::PACKAGE_MANAGER_TYPE_APT, | ||
DockerContainerInterface::PACKAGE_MANAGER_TYPE_APTITUTDE, | ||
DockerContainerInterface::PACKAGE_MANAGER_TYPE_APK, | ||
]); | ||
|
||
return $resolver; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.