Ver código fonte

:wrench: add local react building

Jeremy Zheng 3 anos atrás
pai
commit
4d223c00be

+ 1 - 0
deploy/.gitignore

@@ -1,3 +1,4 @@
 /clients/
 /tmp/
+/roles/mint/files/dashboard/
 *.log

+ 8 - 4
deploy/roles/mint/tasks/main.yml

@@ -88,7 +88,11 @@
   args:
     chdir: "{{ app_deploy_target }}/agile/dashboard"
 
-- name: Build dashboard (agile)
-  ansible.builtin.shell: BUILD_PATH={{ app_deploy_target }}/dashboard PUBLIC_URL=/pcd yarn build
-  args:
-    chdir: "{{ app_deploy_target }}/agile/dashboard"
+- name: Upload dashboard folder
+  ansible.builtin.copy:
+    src: dashboard
+    dest: "{{ app_deploy_target }}/"
+# - name: Build dashboard (agile)
+#   ansible.builtin.shell: NODE_OPTIONS=--max-old-space-size=1024 GENERATE_SOURCEMAP=false BUILD_PATH={{ app_deploy_target }}/dashboard PUBLIC_URL=/pcd yarn build
+#   args:
+#     chdir: "{{ app_deploy_target }}/agile/dashboard"

+ 23 - 3
deploy/roles/ubuntu/tasks/main.yml

@@ -6,6 +6,28 @@
     repo: ppa:ubuntu-toolchain-r/test
   when: ansible_distribution == 'Ubuntu'
 
+# https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable
+- name: Add an yarn signing key
+  become: true
+  ansible.builtin.apt_key:
+    url: https://dl.yarnpkg.com/debian/pubkey.gpg
+    state: present
+  when: ansible_distribution == 'Ubuntu'
+
+- name: Add an yarn package repository
+  become: true
+  ansible.builtin.lineinfile:
+    path: /etc/apt/sources.list.d/yarn.list
+    line: "deb https://dl.yarnpkg.com/debian/ stable main"
+    create: true
+  when: ansible_distribution == 'Ubuntu'
+
+- name: Install nodejs
+  become: true
+  community.general.snap:
+    name: node
+    classic: true
+
 - name: Update system
   become: true
   apt:
@@ -68,8 +90,7 @@
       - screen
       - tmux
       - hugo
-      - nodejs
-      - npm
+      - yarn
       - python3
       - python3-pip
       - python3-distutils
@@ -84,7 +105,6 @@
   apt:
     pkg:
       - systemd-timesyncd
-      - yarnpkg
   # ansible_facts['distribution'] == "Ubuntu"
   when: ansible_facts['distribution_major_version'] | int >= 20
 

+ 17 - 0
deploy/scripts/dashboard.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+
+export WORKSPACE=$PWD
+
+cd $WORKSPACE/dashboard
+if [ ! -d node_modules ]
+then
+    yarn install
+fi
+
+GENERATE_SOURCEMAP=false BUILD_PATH=$WORKSPACE/deploy/roles/mint/files/dashboard PUBLIC_URL=/pcd yarn build
+
+echo 'done.'
+
+exit 0