Skip to content

Commit ad7e18d

Browse files
authored
Ansible (#41)
* Added Ansible * Remove envoy, from composer.json
1 parent d6ab3cb commit ad7e18d

5 files changed

Lines changed: 90 additions & 146 deletions

File tree

‎Envoy.blade.php‎

Lines changed: 0 additions & 81 deletions
This file was deleted.

‎ansible/inventory/production.ini‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[app_servers]
2+
server1 ansible_host=143.198.129.111 ansible_user=root
3+
4+
[local]
5+
127.0.0.1 ansible_connection=local

‎composer.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"barryvdh/laravel-ide-helper": "^3.5",
3636
"beyondcode/laravel-query-detector": "^2.0",
3737
"fakerphp/faker": "^1.23",
38-
"laravel/envoy": "^2.10",
3938
"laravel/pail": "^1.1",
4039
"laravel/pint": "^1.24",
4140
"laravel/sail": "^1.40",

‎composer.lock‎

Lines changed: 1 addition & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deploy.yml‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
- name: Build Frontend Locally
3+
hosts: local
4+
tasks:
5+
- name: Build frontend
6+
shell: |
7+
npm ci && npm run build
8+
args:
9+
chdir: "{{ playbook_dir }}"
10+
when: not skip_frontend | default(false)
11+
12+
13+
- name: Deploy Updates To Server
14+
hosts: app_servers
15+
become: yes
16+
vars:
17+
project_path: /var/www/ComputerScienceResources.com
18+
repo_url: git@github.com:AllanKoder/ComputerScienceResources.com.git
19+
20+
tasks:
21+
- name: Ensure project directory exists
22+
file:
23+
path: /var/www/ComputerScienceResources.com/public
24+
state: directory
25+
mode: '0755'
26+
owner: www-data
27+
group: www-data
28+
29+
- name: Push frontend as new_build
30+
synchronize:
31+
src: "{{ playbook_dir }}/public/build/"
32+
dest: /var/www/ComputerScienceResources.com/public/new_build/
33+
recursive: yes
34+
35+
- name: Backup database
36+
command: php artisan backup:run --only-db
37+
args:
38+
chdir: "{{ project_path }}"
39+
when: not skip_backup | default(false)
40+
41+
- name: Bring app down
42+
command: php artisan down
43+
args:
44+
chdir: "{{ project_path }}"
45+
46+
- name: Update code
47+
git:
48+
repo: "{{ repo_url }}"
49+
dest: "{{ project_path }}"
50+
version: master
51+
52+
- name: Install PHP dependencies
53+
shell: |
54+
php -d memory_limit=-1 $(which composer) install \
55+
--no-dev \
56+
--optimize-autoloader \
57+
--prefer-dist \
58+
--no-interaction
59+
args:
60+
chdir: "{{ project_path }}"
61+
62+
- name: Run migrations
63+
command: php artisan migrate --force
64+
args:
65+
chdir: "{{ project_path }}"
66+
67+
- name: Swap new_build into build
68+
command: mv /var/www/ComputerScienceResources.com/public/new_build /var/www/ComputerScienceResources.com/public/build
69+
when: not skip_frontend | default(false)
70+
71+
- name: Optimize caches
72+
command: php artisan {{ item }}
73+
args:
74+
chdir: "{{ project_path }}"
75+
loop:
76+
- cache:clear
77+
- config:cache
78+
- route:cache
79+
- view:cache
80+
81+
- name: Bring app up
82+
command: php artisan up
83+
args:
84+
chdir: "{{ project_path }}"

0 commit comments

Comments
 (0)