-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bohdan Khrupa
committed
Apr 4, 2018
1 parent
8f10ef0
commit 9f61dc6
Showing
8 changed files
with
160 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.retry |
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,23 @@ | ||
--- | ||
- name: Deploy application to local server | ||
hosts: local | ||
vars: | ||
ansistrano_deploy_from: "{{ playbook_dir }}" | ||
ansistrano_deploy_to: "/tmp/deploy" | ||
ansistrano_keep_releases: 3 | ||
ansistrano_deploy_via: git | ||
ansistrano_git_repo: [email protected]:vendor/project.git | ||
ansistrano_git_branch: develop | ||
|
||
ansistrano_shared_paths: | ||
- storage | ||
ansistrano_shared_files: | ||
- .env | ||
|
||
# Additional task | ||
ansistrano_after_symlink_shared_tasks_file: "{{ playbook_dir }}/tasks/dev/after-symlink-shared.yml" | ||
ansistrano_before_symlink_tasks_file: "{{ playbook_dir }}/tasks/dev/before-symlink.yml" | ||
ansistrano_after_cleanup_tasks_file: "{{ playbook_dir }}/tasks/dev/after-cleanup.yml" | ||
|
||
roles: | ||
- { role: carlosbuenosvinos.ansistrano-deploy } |
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,3 @@ | ||
local ansible_host=localhost | ||
dev ansible_host=development-server-ssh-alias | ||
|
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,4 @@ | ||
- name: Enable application | ||
shell: php artisan up | ||
args: | ||
chdir: /tmp/deploy/current |
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,23 @@ | ||
# Custom php and composer path | ||
#- name: Composer install all dependencies | ||
# shell: | | ||
# export PATH=/opt/plesk/php/7.0/bin::$PATH; | ||
# /opt/plesk/php/7.0/bin/php /usr/lib64/plesk-9.0/composer.phar install | ||
# args: | ||
# chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Composer install all dependencies | ||
shell: composer install | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Check code style | ||
shell: php artisan code-style | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Cleare testing sqlite database | ||
shell: echo '' > ./database/database.sqlite | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Run tests | ||
shell: ./vendor/bin/phpunit | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" |
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,25 @@ | ||
- name: Disable application | ||
shell: php artisan down | ||
args: | ||
chdir: /tmp/deploy/current | ||
# DO NOT run migration and db:seed in the Production servers! | ||
- name: Migrate DataBase | ||
shell: php artisan migrate --force | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Seed DataBase only 'production' seeders | ||
shell: php artisan db:seed --env=production --force | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Create storage symlink | ||
shell: php artisan storage:link -q | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Cleare view cache | ||
shell: php artisan view:clear | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" | ||
- name: Cleare application cache | ||
shell: php artisan cache:clear | ||
args: | ||
chdir: "{{ ansistrano_release_path.stdout }}" |
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,79 @@ | ||
# Deploy | ||
|
||
## Development Server | ||
|
||
Deploy command | ||
|
||
``` | ||
$ ansible-playbook -i config/deploy/hosts config/deploy/deploy-dev.yml | ||
``` | ||
|
||
|
||
## Setup | ||
|
||
Install **Ansible** and **Ansistrano** | ||
|
||
``` | ||
$ ansible --version | ||
ansible 2.1.1.0 | ||
``` | ||
|
||
Install [Ansistrano playbooks](https://github.com/ansistrano/deploy#installation) | ||
|
||
``` | ||
$ sudo ansible-galaxy install carlosbuenosvinos.ansistrano-deploy carlosbuenosvinos.ansistrano-rollback --ignore-errors | ||
``` | ||
|
||
|
||
|
||
## Local ssh config and ForwardAgent | ||
|
||
Add host-alias to ssh config. | ||
|
||
``` | ||
$ cat ~/.ssh/config | ||
# development server | ||
Host development-server-ssh-alias | ||
Hostname localhost | ||
Port 22 | ||
User FIX_USER_NAME | ||
ForwardAgent yes | ||
# EOT development server | ||
``` | ||
|
||
Then use only host-alias on the **inventor** **hosts** file | ||
|
||
|
||
|
||
## First run | ||
|
||
Steps for prepare deploy environment, just example paths. | ||
|
||
1. Server must satisfy all requirements | ||
2. Prepare folders and environment | ||
|
||
``` | ||
$ mkdir -p /tmp/deploy/shared | ||
$ cp -r ./storage /tmp/deploy/shared | ||
$ cp ./.env.example /tmp/deploy/shared/.env | ||
``` | ||
3. Create temporary current folder and `artisan` file | ||
``` | ||
$ mkdir -p /tmp/deploy/current/public | ||
$ touch /tmp/deploy/current/artisan | ||
``` | ||
5. Add **APP_ENV** and **APP_KEY** | ||
``` | ||
$ vim /tmp/deploy/shared/.env | ||
``` | ||
Example | ||
``` | ||
APP_ENV=production | ||
APP_KEY=base64:eBzXep0nTYQg4TBGgibKB98C0P9GHdBoolmsOzLNksg= | ||
``` |
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