Procházet zdrojové kódy

:wrench: add mint v2 deploy support

Jeremy Zheng před 2 roky
rodič
revize
bd0e6d5ad1

+ 34 - 5
deploy/mint.yml

@@ -1,9 +1,38 @@
-- hosts: all
+- name: "local compile"
+  hosts: localhost
+  connection: local
+  tasks:
+    - name: "install dashboard dependencies"
+      ansible.builtin.shell:
+        cmd: yarn install
+        chdir: "{{ playbook_dir }}/../dashboard"
+    - name: "build dashboard"
+      ansible.builtin.shell:
+        cmd: NODE_OPTIONS="--max_old_space_size=4096" PUBLIC_URL=/pcd yarn build
+        chdir: "{{ playbook_dir }}/../dashboard"
+
+- hosts:
+    - www
+    - php_fpm
+  tasks:
+    - name: create deployment folder
+      become: true
+      ansible.builtin.file:
+        path: "{{ app_deploy_root }}"
+        state: directory
+        owner: "{{ ansible_user }}"
+    - name: create logs folder
+      become: true
+      ansible.builtin.file:
+        path: "{{ app_deploy_root }}/logs"
+        state: directory
+        owner: "www-data"
+        group: "www-data"
+
+- hosts: php_fpm
   roles:
-    - ubuntu
-    - os
+    - laravel
 
 - hosts: www
   roles:
-    - php
-    - mint
+    - dashboard

+ 4 - 0
deploy/roles/dashboard/tasks/main.yml

@@ -0,0 +1,4 @@
+- name: upload dashboard
+  ansible.builtin.copy:
+    src: "{{ playbook_dir }}/../dashboard/build/"
+    dest: "{{ app_deploy_root }}/dashboard/"

+ 50 - 0
deploy/roles/laravel/tasks/main.yml

@@ -0,0 +1,50 @@
+- name: Install node.js packages
+  become: true
+  apt:
+    pkg:
+      - nodejs
+      - npm
+      - yarnpkg
+
+# https://laravel.com/docs/10.x/deployment
+
+- name: clone source code
+  ansible.builtin.git:
+    repo: "https://github.com/iapt-platform/mint.git"
+    dest: "{{ app_deploy_root }}/htdocs"
+    version: "laravel"
+
+- name: install nodejs packages for v1
+  ansible.builtin.shell:
+    cmd: yarnpkg install
+    chdir: "{{ app_deploy_root }}/htdocs/public"
+
+- name: install nodejs packages for v2
+  ansible.builtin.shell:
+    cmd: yarnpkg install
+    chdir: "{{ app_deploy_root }}/htdocs"
+
+- name: autoloader Optimization
+  ansible.builtin.shell:
+    cmd: composer install --optimize-autoloader --no-dev
+    chdir: "{{ app_deploy_root }}/htdocs"
+
+- name: caching configuration
+  ansible.builtin.shell:
+    cmd: php artisan config:cache
+    chdir: "{{ app_deploy_root }}/htdocs"
+
+- name: caching events
+  ansible.builtin.shell:
+    cmd: php artisan event:cache
+    chdir: "{{ app_deploy_root }}/htdocs"
+
+- name: caching routes
+  ansible.builtin.shell:
+    cmd: php artisan route:cache
+    chdir: "{{ app_deploy_root }}/htdocs"
+
+- name: caching views
+  ansible.builtin.shell:
+    cmd: php artisan view:cache
+    chdir: "{{ app_deploy_root }}/htdocs"