M
M
mirexdoors2020-02-03 13:25:08
Continuous Delivery
mirexdoors, 2020-02-03 13:25:08

How to properly deploy a node.js application?

Hello! Can you please tell me how to properly deploy a node.js application through the bitbucket pipeline?

I have this yml

image: node:10.15.3

pipelines:
  custom: # Pipelines that are triggered manually
    deployment-to-production-init:
      - step:
          caches:
            - node
          script: # Modify the commands below to build your repository.
             - npm install
             - npm rebuild node-sass --force
             - apt-get update
             - apt-get -qq install git-ftp
             - echo "'_$(git status -uno --porcelain | wc -l)_'"
             - git status -uno --porcelain
             - echo "Initiating Push site:Source"
             - git ftp init --user $FTP_LOGIN --passwd $FTP_PASSWORD ftp://$FTP_HOST/public_html/

    deployment-to-production:
      - step:
          caches:
            - node
          script: # Modify the commands below to build your repository.
             - npm install
             - npm rebuild node-sass --force
             - apt-get update
             - apt-get -qq install git-ftp
             - echo "'_$(git status -uno --porcelain | wc -l)_'"
             - git status -uno --porcelain
             - echo "Initiating Push site:Source"
             - git ftp push --user $FTP_LOGIN --passwd $FTP_PASSWORD ftp://$FTP_HOST/public_html/

  branches: # Pipelines that run automatically on a commit to a branch
    master:
     - step:
        caches:
          - node
        script:
          - apt-get update
          - npm install
          - npm rebuild node-sass --force
          - git ftp push --user $FTP_LOGIN --passwd $FTP_PASSWORD ftp://$FTP_HOST/public_html/
          - /bin/bash start_server.sh

and bash script:
#!/usr/bin/env bash
npm install
export NODE_ENV=production
forever server.js


The idea is not to upload the node_modules folder every time, but to install dependencies already on the server. But for some reason, the problem is that when starting_server.sh is executed, node_modules are not installed on ftp, although the script seems to start in the bitbucket console

+ /bin/bash start_server.sh
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
audited 128 packages in 0.878s
found 0 vulnerabilities

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question