Просмотр исходного кода

:wrench: add mint v2.3 build scripts

China Kassapa 2 месяцев назад
Родитель
Сommit
2aec549783

+ 15 - 10
deploy/group_vars/all.yml

@@ -3,18 +3,23 @@ ansible_python_interpreter: /usr/bin/python3
 ansible_ssh_private_key_file: "{{ inventory_dir }}/.ssh/id_ed25519"
 
 app_deploy_target: "/srv/{{ app_domain }}/mint-{{ mint_version }}"
-app_build_target: "{{ ansible_env.HOME }}/build/{{ app_domain }}/mint-{{ mint_version }}"
-app_downloads: "{{ ansible_env.HOME }}/downloads"
 app_debug: false
 
-app_dashboard_base_path: "/pcd"
-app_postgresql_version: "16"
-app_open_search_version: "2.19.1"
-app_python_version: "3.13"
-app_php_version: "8.1"
-app_php_fpm_port: 9081
+app_api_v8_php_base_path: "/api"
+app_api_v8_php_version: "8.1"
+app_api_v8_php_fpm_port: 9810
+app_api_v8_php_image: "wikipali/mint:php-8.1-20251225"
+
+app_api_v12_php_base_path: "/api-v2026"
+app_api_v12_php_version: "8.4"
+app_api_v12_php_fpm_port: 9840
+app_api_v12_php_image: "wikipali/mint:php-8.4-20260108"
+
+app_dashboard_v4_base_path: "/pcd"
+app_dashboard_v6_base_path: "/pcd-v2026"
+
+app_dashboard_token_key: "token.20260116"
 app_php_memory_limit: "128M"
-app_container_prefix: "mint"
 app_consumer_loop_limit_ai_translate: 16
 
-app_docker_image_name: "magnolia"
+app_python_image: "wikipali/mint:php-8.4-20260108"

+ 31 - 0
deploy/mint-v2.2.yml

@@ -0,0 +1,31 @@
+- name: Setup local build folder
+  hosts: localhost
+  tasks:
+    - name: Git checkout repo
+      ansible.builtin.git:
+        repo: "https://github.com/iapt-platform/mint.git"
+        dest: "{{ playbook_dir }}/tmp/mint"
+        version: "{{ mint_version }}"
+
+- name: Build on local
+  hosts: localhost
+  roles:
+    - mint-dashboard-v4-build
+    - mint-openai-proxy-build
+    - clove-build
+
+- name: Build mint package on remote
+  hosts: building
+  roles:
+    - mint-release-build
+
+- name: Setup deploy folder
+  hosts: all:!localhost
+  roles:
+    - mint-v2.2
+
+- name: Setup nginx
+  hosts:
+    - web
+  roles:
+    - mint-nginx

+ 34 - 26
deploy/mint.yml

@@ -1,31 +1,39 @@
-- name: Setup local build folder
-  hosts: localhost
-  tasks:
-    - name: Git checkout repo
-      ansible.builtin.git:
-        repo: "https://github.com/iapt-platform/mint.git"
-        dest: "{{ playbook_dir }}/tmp/mint"
-        version: "{{ mint_version }}"
-
-- name: Build on local
+- name: Building mint release package
   hosts: localhost
   roles:
-    - mint-dashboard-v4-build
-    - mint-openai-proxy-build
-    - clove-build
+    - mint-build-v2.3
+  vars:
+    app_workspace: "{{ ansible_facts['env']['HOME'] }}/build/mint"
 
-- name: Build mint package on remote
-  hosts: building
-  roles:
-    - mint-release-build
 
-- name: Setup deploy folder
-  hosts: all:!localhost
-  roles:
-    - mint-v2.2
+# - name: Setup local build folder
+#   hosts: localhost
+#   tasks:
+#     - name: Git checkout repo
+#       ansible.builtin.git:
+#         repo: "https://github.com/iapt-platform/mint.git"
+#         dest: "{{ playbook_dir }}/tmp/mint"
+#         version: "{{ mint_version }}"
 
-- name: Setup nginx
-  hosts:
-    - web
-  roles:
-    - mint-nginx
+# - name: Build on local
+#   hosts: localhost
+#   roles:
+#     - mint-dashboard-v4-build
+#     - mint-openai-proxy-build
+#     - clove-build
+
+# - name: Build mint package on remote
+#   hosts: building
+#   roles:
+#     - mint-release-build
+
+# - name: Setup deploy folder
+#   hosts: all:!localhost
+#   roles:
+#     - mint-v2.2
+
+# - name: Setup nginx
+#   hosts:
+#     - web
+#   roles:
+#     - mint-nginx

+ 0 - 0
deploy/roles/mint-build-v2.3/files/.gitignore


+ 129 - 0
deploy/roles/mint-build-v2.3/tasks/main.yml

@@ -0,0 +1,129 @@
+- name: Create build folder
+  ansible.builtin.file:
+    path: "{{ app_workspace | dirname }}"
+    state: directory
+    owner: "{{ ansible_user }}"
+    mode: "0755"
+
+- name: Git checkout mint repo
+  ansible.builtin.git:
+    repo: "https://github.com/iapt-platform/mint.git"
+    dest: "{{ app_workspace }}"
+    version: "{{ mint_version }}"
+
+- name: Extract dashboard-v4
+  ansible.builtin.unarchive:
+    src: dashboard-v4-{{ ansible_facts['architecture'] }}-20260116065749.tar.xz
+    dest: "{{ app_workspace }}/dashboard-v4/dashboard"
+    creates: "{{ app_workspace }}/dashboard-v4/dashboard/yarn.lock"
+
+- name: Extract api-v8
+  ansible.builtin.unarchive:
+    src: api-v8-{{ ansible_facts['architecture'] }}-20260116065749.tar.xz
+    dest: "{{ app_workspace }}/api-v8"
+    creates: "{{ app_workspace }}/api-v8/composer.lock"
+
+- name: Extract dashboard-v6
+  ansible.builtin.unarchive:
+    src: dashboard-v6-{{ ansible_facts['architecture'] }}-20260116064312.tar.xz
+    dest: "{{ app_workspace }}/dashboard-v6"
+    creates: "{{ app_workspace }}/dashboard-v6/package-lock.json"
+
+- name: Extract api-v12
+  ansible.builtin.unarchive:
+    src: api-v12-{{ ansible_facts['architecture'] }}-20260116064312.tar.xz
+    dest: "{{ app_workspace }}/api-v12"
+    creates: "{{ app_workspace }}/api-v12/composer.lock"
+
+- name: Extract open-ai-server
+  ansible.builtin.unarchive:
+    src: open-ai-server-{{ ansible_facts['architecture'] }}-20260116064312.tar.xz
+    dest: "{{ app_workspace }}/open-ai-server"
+    creates: "{{ app_workspace }}/open-ai-server/package-lock.json"
+
+- name: Build dashboard-v4
+  ansible.builtin.shell: |
+    source ~/.nvm/nvm.sh && yarn build
+  args:
+    executable: /bin/bash
+    chdir: "{{ app_workspace }}/dashboard-v4/dashboard"
+    creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v6"
+  environment:
+    BUILD_PATH: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v4"
+    NODE_OPTIONS: "--max_old_space_size=5120"
+    PUBLIC_URL: "{{ app_dashboard_v4_base_path }}"
+    REACT_APP_DEFAULT_LOCALE: "zh-Hans"
+    REACT_APP_LANGUAGES: "en-US,zh-Hans,zh-Hant"
+    REACT_APP_ENABLE_LOCAL_TOKEN: "true"
+    REACT_APP_TOKEN_KEY: "{{ app_dashboard_token_key }}"
+    REACT_APP_DOCUMENTS_SERVER: "{{ app_documents_server }}"
+    REACT_APP_RPC_SERVER: "{{ app_grpc_web_server }}"
+    REACT_APP_ASSETS_SERVER: "{{ app_assets_server }}"
+    REACT_APP_API_SERVER: "https://{{ app_domain }}"
+    REACT_APP_ICP_CODE: "{{ app_icp_code }}"
+    REACT_APP_MPS_CODE: "{{ app_mps_code }}"
+    REACT_APP_QUESTIONNAIRE_LINK: "{{ app_questionnaire_link }}"    
+    REACT_APP_OPENAI_PROXY: "{{ app_openai_proxy_server }}/api/openai"
+      
+
+- name: Build dashboard-v6
+  ansible.builtin.shell: |
+    source ~/.nvm/nvm.sh && vite build --base={{ app_dashboard_v6_base_path }} --outDir {{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v6
+  args:
+    executable: /bin/bash
+    chdir: "{{ app_workspace }}/dashboard-v6"
+    creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v6"
+  environment:
+    NODE_ENV: production
+    VITE_DEFAULT_LOCALE: "zh-Hans"
+    VITE_LANGUAGES: "en-US,zh-Hans,zh-Hant"
+    VITE_ENABLE_LOCAL_TOKEN: "true"
+    VITE_TOKEN_KEY: "{{ app_dashboard_token_key }}"
+    VITE_DOCUMENTS_SERVER: "{{ app_documents_server }}"
+    VITE_RPC_SERVER: "{{ app_grpc_web_server }}"
+    VITE_ASSETS_SERVER: "{{ app_assets_server }}"
+    VITE_API_SERVER: "https://{{ app_domain }}"
+    VITE_ICP_CODE: "{{ app_icp_code }}"
+    VITE_MPS_CODE: "{{ app_mps_code }}"
+    VITE_QUESTIONNAIRE_LINK: "{{ app_questionnaire_link }}"    
+    VITE_OPENAI_PROXY: "{{ app_openai_proxy_server }}/api/openai"
+    
+- name: Build open-ai proxy server
+  ansible.builtin.shell: |
+    source ~/.nvm/nvm.sh && webpack --config webpack.config.js --output-path {{ app_workspace }}/open-ai-server
+  args:
+    executable: /bin/bash
+    chdir: "{{ app_workspace }}/open-ai-server"
+    creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/open-ai-server"
+  environment:
+    NODE_ENV: production
+    
+- name: Copy api-v8 to release folder
+  ansible.builtin.copy:
+    remote: true
+    src: "{{ app_workspace }}/api-v8"
+    dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/api-v8/"
+    mode: '0755'
+  args:
+    creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/api-v8"
+
+- name: Copy api-v12 to release folder
+  ansible.builtin.copy:
+    remote: true
+    src: "{{ app_workspace }}/api-v12"
+    dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/api-v12/"
+    mode: '0755'
+  args:
+    creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/api-v12"
+
+- name: Archive only the contents of the /var/www/html folder
+  community.general.archive:
+    path: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/*"
+    dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}.tar.xz"
+    format: xz
+    remove: true
+ 
+- name: Download mint.tar.xz
+    ansible.builtin.fetch:
+      src: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}.tar.xz"
+      dest: "{{ playbook_dir }}/tmp/"

+ 0 - 0
deploy/roles/mint-v2.3/tasks/build.yml


+ 3 - 0
deploy/roles/mint-v2.3/tasks/main.yml

@@ -0,0 +1,3 @@
+- name: Setup clove
+  ansible.builtin.import_tasks: build.yml
+  

+ 3 - 0
scripts/3rd-pack.sh

@@ -20,10 +20,13 @@ elif [[ "$PHP_VERSION" == "8.4.16" ]]; then
     npm install
     cd $WORKSPACE/dashboard-v6/
     npm install
+    cd $WORKSPACE/open-ai-server/
+    npm install
 
     cd $WORKSPACE/
     $TAR api-v12-$VERSION.tar.xz -C api-v12 node_modules package-lock.json vendor composer.lock    
     $TAR dashboard-v6-$VERSION.tar.xz -C dashboard-v6 node_modules package-lock.json
+    $TAR open-ai-server-$VERSION.tar.xz -C open-ai-server node_modules package-lock.json
 else
     echo "unsupported php version $PHP_VERSION"
     exit 1