@Iceforest

Как ускорить сборку npm пакетов?

Добрый день, при сборке сервера с помощью ansible в ямл файле есть шаг установки npm install. Данный шаг занимает много времени и ресурсов. Можно ли как то ускорить сборку?
- hosts: frontend_servers

  vars:
    project_path: /var/www
    repositiry: ссылка на репозиторий


  tasks:

    - name: "Yarn | GPG"
      apt_key:
        url: https://dl.yarnpkg.com/debian/pubkey.gpg
        state: present

    - name: "Yarn | Ensure Debian sources list file exists"
      file:
        path: /etc/apt/sources.list.d/yarn.list
        owner: root
        mode: 0644
        state: touch

    - name: "Yarn | Ensure Debian package is in sources list"
      lineinfile:
        dest: /etc/apt/sources.list.d/yarn.list
        regexp: 'deb http://dl.yarnpkg.com/debian/ stable main'
        line: 'deb http://dl.yarnpkg.com/debian/ stable main'
        state: present

    - name: "Yarn | Update APT cache"
      apt:
        update_cache: yes

    - name: Install the packages YARN, NPM, NodeJS, Nginx
      apt: 
        pkg: 
          - yarn
          - npm
          - nodejs

    - name: Remove Nginx
      apt:
        name: nginx
        state: absent

    - name: Stop service Nginx
      ansible.builtin.systemd:
        name: nginx
        state: stopped

    - name: Delete the html file 
      file:
        path: "{{ project_path }}/html"
        state: absent

    - name: Set some variable
      set_fact:
        release_path: "{{ project_path }}/releases/{{ lookup('pipe','date +%Y%m%d%H%M%S') }}"
        current_path: "{{ project_path }}/html"
      tags: start_yarn

    - name: Create project path
      file:
        dest={{ project_path }}
        mode=0755
        recurse=yes
        state=directory

    - name: Retrieve current release folder
      command: readlink -f html
      register: current_release_path
      ignore_errors: yes
      args:
        chdir: "{{ project_path }}"

    - name: Create Release folder
      file:
        dest={{ release_path }}
        mode=0755
        recurse=yes
        state=directory

    - name: Clone the repository
      git:
        repo: "{{ repositiry }}"
        dest: "{{ release_path }}"


    - name: Add IP address of instance to main site 
      replace:
        path: "{{ release_path }}/src/App.js"
        regexp: 'Test of revert'
        replace: '{{ ansible_default_ipv4.address }}'
        backup: yes

    - name: Install packages based on package.json.
      npm:
        path: "{{ release_path }}"

    - name: npm install
      command: "npm install"
      args:
        chdir: "{{ release_path }}"


    - name: Start application
      command: "nohup yarn start &"
      args:
        chdir: "{{ release_path }}"
      environment:
        PORT: 80
      async: 1000
      poll: 0
      tags: start_yarn

собираю с помощью команды ansible-playbook -b reactjs.yaml -vv
  • Вопрос задан
  • 409 просмотров
Решения вопроса 1
@Iceforest Автор вопроса
npm заменил на yarn
- name: yarn install
command: "yarn install"
args:
chdir: "{{ release_path }}"
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
opium
@opium
Просто люблю качественно работать
так он это делает один раз долго потом уже все пакеты стоят
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы