Prechádzať zdrojové kódy

:bug: fix mint v2 deployment

Jeremy Zheng 2 rokov pred
rodič
commit
f06712b3ff

+ 13 - 12
deploy/mint.yml

@@ -1,15 +1,16 @@
-- 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"
+# - 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
   roles:
     - mint-v2

+ 76 - 8
deploy/roles/mint-v2/tasks/laravel.yml

@@ -6,38 +6,106 @@
     dest: "{{ app_deploy_root }}/htdocs"
     version: "laravel"
 
+- name: install nodejs packages for v2
+  ansible.builtin.shell:
+    cmd: yarnpkg install
+    chdir: "{{ app_deploy_root }}/htdocs"
+
 - name: install nodejs packages for v1
   ansible.builtin.shell:
     cmd: yarnpkg install
     chdir: "{{ app_deploy_root }}/htdocs/public"
 
-- name: install nodejs packages for v2
+- name: upload .env(v2)
+  become: true
+  template:
+    src: v2/env.j2
+    dest: "{{ app_deploy_root }}/htdocs/.env"
+    owner: www-data
+    group: www-data
+    mode: "0400"
+
+- name: upload config.php(v1)
+  become: true
+  template:
+    src: v1/config.php.j2
+    dest: "{{ app_deploy_root }}/htdocs/public/app/config.php"
+    owner: www-data
+    group: www-data
+    mode: "0400"
+
+- name: upload config.js(v1)
+  become: true
+  template:
+    src: v1/config.js.j2
+    dest: "{{ app_deploy_root }}/htdocs/public/app/config.js"
+    owner: www-data
+    group: www-data
+    mode: "0444"
+
+- name: setup bootstrap folder
+  become: true
+  ansible.builtin.file:
+    path: "{{ app_deploy_root }}/htdocs/bootstrap/cache"
+    state: directory
+    owner: www-data
+    group: www-data
+    recurse: yes
+
+- name: setup storage folder
+  become: true
+  ansible.builtin.file:
+    path: "{{ app_deploy_root }}/htdocs/storage"
+    state: directory
+    owner: www-data
+    group: www-data
+    recurse: yes
+
+- name: auto-loader optimization for v2
   ansible.builtin.shell:
-    cmd: yarnpkg install
+    cmd: composer install --optimize-autoloader --no-dev
     chdir: "{{ app_deploy_root }}/htdocs"
 
-- name: autoloader Optimization
+- name: auto-loader optimization for v1
   ansible.builtin.shell:
     cmd: composer install --optimize-autoloader --no-dev
-    chdir: "{{ app_deploy_root }}/htdocs"
+    chdir: "{{ app_deploy_root }}/htdocs/public"
 
 - name: caching configuration
+  become: true
   ansible.builtin.shell:
-    cmd: php artisan config:cache
+    cmd: su www-data -pc "php artisan config:cache"
     chdir: "{{ app_deploy_root }}/htdocs"
 
 - name: caching events
+  become: true
   ansible.builtin.shell:
-    cmd: php artisan event:cache
+    cmd: su www-data -pc "php artisan event:cache"
     chdir: "{{ app_deploy_root }}/htdocs"
 
 - name: caching routes
+  become: true
   ansible.builtin.shell:
-    cmd: php artisan route:cache
+    cmd: su www-data -pc "php artisan route:cache"
     chdir: "{{ app_deploy_root }}/htdocs"
 
 - name: caching views
+  become: true
   ansible.builtin.shell:
-    cmd: php artisan view:cache
+    cmd: su www-data -pc "php artisan view:cache"
     chdir: "{{ app_deploy_root }}/htdocs"
 
+- name: create tmp folder for v1
+  become: true
+  ansible.builtin.file:
+    path: "{{ app_deploy_root }}/htdocs/public/tmp"
+    state: directory
+    owner: "www-data"
+    group: "www-data"
+
+- name: setup sqlite3 db for v1
+  become: true
+  ansible.builtin.file:
+    src: /var/www/shared/appdata
+    dest: "{{ app_deploy_root }}/htdocs/public/tmp/appdata"
+    state: link

+ 1 - 1
deploy/roles/mint-v2/tasks/main.yml

@@ -1,3 +1,3 @@
 - import_tasks: init.yml
 - import_tasks: laravel.yml
-- import_tasks: dashboard.yml
+# - import_tasks: dashboard.yml

+ 14 - 0
deploy/roles/mint-v2/templates/v1/config.js.j2

@@ -0,0 +1,14 @@
+var RPC_SERVER = "{{ app_rpc_server }}";
+
+/*
+  |---------------
+  |网站资源文件,非用户的图片,音频,视频
+  |---------------
+  |对应/public/tmp/ 目录 开发线可以设置为 http://127.0.0.1:8000/tmp
+  |所有文件存储在 https://drive.google.com/drive/folders/1-4dn4juD-0-lsKndDui2W9nT9wcS_Y33?usp=sharing
+  |开发线可自行下载放到/public/tmp/
+  |或直接引用离您最近的assets server
+  |------------------------
+*/
+
+var ASSETS_SERVER = "{{ app_assets_server }}"

+ 62 - 0
deploy/roles/mint-v2/templates/v1/config.php.j2

@@ -0,0 +1,62 @@
+<?php
+
+#域名设置
+define("RPC_SERVER","{{ app_rpc_server}}");
+define("ASSETS_SERVER","{{ app_assets_server }}");
+define('APP_KEY','{{ app_secret_key }}');
+/*
+电子邮件设置
+PHPMailer
+*/
+define("Email", [
+                                 "Host"=>"{{ app_smtp_host }}",//Set the SMTP server to send through
+                                 "SMTPAuth"=>true,//Enable SMTP authentication
+                                 "Username"=>'{{ app_smtp_user }}',//SMTP username
+                                 "Password"=>'{{ app_smtp_password }}',//SMTP password
+                                 "Port"=>{{ app_smtp_port }},//TCP port to connect to 465; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
+                                 "From"=>"{{ app_smtp_user }}",
+                                 "Sender"=>"webmaster"
+                                 ]);
+
+/*
+数据库设置
+*/
+define("Database",[
+        "type"=>"pgsql",
+        "server"=>"{{ app_postgresql_host }}",
+        "port"=>{{ app_postgresql_port }},
+        "name"=>"{{ app_postgresql_dbname }}",
+        "sslmode" => "disable",
+        "user" => "{{ app_postgresql_user }}",
+        "password" => "{{ app_postgresql_password }}"
+]);
+
+
+/*
+Redis 设置,
+*/
+define("Redis",[        
+        "host" => "{{ app_redis_host }}",
+        "port" => {{ app_redis_port }},
+        "password" => "",
+        "prefix"=>"{{ app_deploy_env }}://www"
+]);
+
+
+# 雪花id
+define("SnowFlake",[
+        "DatacenterId"=>{{ app_snowflake_data_center_id }},
+        "WorkerId"=>{{ app_snowflake_worker_id }}
+]);
+
+#目录设置,不能更改
+require_once __DIR__."/config.dir.php";
+
+/*
+数据表
+*/
+#表设置,此行不能更改
+require_once __DIR__."/config.table.php";
+
+
+?>

+ 75 - 0
deploy/roles/mint-v2/templates/v2/env.j2

@@ -0,0 +1,75 @@
+BASE_DIR="{{ app_deploy_root }}/.env.global"
+CACHE_DIR="${BASE_DIR}/cache"
+TMP_DIR="${BASE_DIR}/tmp"
+
+APP_NAME="wikipali"
+APP_ENV=production
+APP_KEY={{ app_secret_key }}
+APP_DEBUG=false
+APP_URL="https://{{ app_domain }}"
+DASHBOARD_URL="https://{{ app_domain }}/pcd"
+
+LOG_CHANNEL=stack
+LOG_DEPRECATIONS_CHANNEL=null
+LOG_LEVEL=info
+
+DB_CONNECTION=pgsql
+DB_HOST={{ app_postgresql_host }}
+DB_PORT={{ app_postgresql_port }}
+DB_DATABASE={{ app_postgresql_dbname }}
+DB_USERNAME={{ app_postgresql_user }}
+DB_PASSWORD="{{ app_postgresql_password }}"
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=redis
+FILESYSTEM_DRIVER=local
+QUEUE_CONNECTION=sync
+SESSION_DRIVER=cookie
+SESSION_LIFETIME=120
+
+REDIS_HOST={{ app_redis_host }}
+REDIS_PORT={{ app_redis_port }}
+REDIS_PASSWORD=
+REDIS_DB=0
+REDIS_PREFIX="${APP_NAME}://{{ app_deploy_env }}/"
+
+REDIS_CACHE_HOST={{ app_redis_cache_host }}
+REDIS_CACHE_PORT={{ app_redis_cache_port }}
+REDIS_CACHE_PASSWORD=
+REDIS_CACHE_DB={{ app_redis_cache_db }}
+REDIS_CACHE_PREFIX="{{ app_deploy_env }}://"
+
+
+MAIL_MAILER=smtp
+MAIL_HOST={{ app_smtp_host }}
+MAIL_PORT={{ app_smtp_port }}
+MAIL_USERNAME="{{ app_smtp_user }}"
+MAIL_PASSWORD="{{ app_smtp_password }}"
+MAIL_ENCRYPTION=ssl
+MAIL_FROM_ADDRESS="{{ app_smtp_user }}"
+MAIL_FROM_NAME="webmaster"
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+AWS_USE_PATH_STYLE_ENDPOINT=false
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=
+PUSHER_APP_CLUSTER=mt1
+
+MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+ASSETS_SERVER="{{ app_assets_server }}"
+RPC_SERVER="{{ app_rpc_server }}"
+SNOWFLAKE_DATA_CENTER_ID={{ app_snowflake_data_center_id }}
+SNOWFLAKE_WORKER_ID={{ app_snowflake_worker_id }}
+
+RABBITMQ_HOST="{{ app_rabbitmq_host }}"
+RABBITMQ_PORT={{ app_rabbitmq_port }}
+RABBITMQ_VIRTUAL_HOST="{{ app_rabbitmq_virtual_host }}"
+RABBITMQ_USER="{{ app_rabbitmq_user }}"
+RABBITMQ_PASSWORD="{{ app_rabbitmq_password }}"