【问题标题】:How to write bitbucket pipeline for deploying my angular universal app?如何编写用于部署我的 Angular 通用应用程序的 bitbucket 管道?
【发布时间】:2020-11-03 09:00:24
【问题描述】:

我正在尝试通过 bitbucket 管道在服务器上部署我的 Angular 通用应用程序。我在bitbucket-pipelines.yml写了如下脚本:

pipelines:
  default:
    - step:
        name: Build app
        caches:
          - node
        script:
          - npm install
          - npm install -g @angular/cli
          - npm run build:ssr
          - npm run serve:ssr
        artifacts:
          - dist/**

我的package.json 有以下脚本:

"scripts": {
        "ng": "ng",
        "start": "ng serve -c=dev -o",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
        "serve:ssr": "node dist/server.js",
        "build:client-and-server-bundles": "ng build --prod && ng run my-app:server",
        "webpack:server": "webpack --config webpack.server.config.js --progress --colors"
    },

当npm run serve:ssr 执行时,我看到它给出了与本地主机相同的输出,即Node server listening on http://localhost:4000。它卡在这一点上。我在这里做错了什么?

【问题讨论】:

    标签: angular pipeline continuous-deployment angular-universal bitbucket-pipelines


    【解决方案1】:

    我认为您需要添加一个远程服务器,您可以在下面的 .yml 文件示例中看到

    image: node:10
    
    pipelines:
      branches:
        master:
          - step:
              name: Installation
              caches:
                - node
              script:
                - npm install
              artifacts:
                - node_modules/** # Save modules for next steps
          - step:
              name: Lint
              script:
                - npm run lint
          - step:
              name: Build
              script:
                - npm run build:production
              artifacts:
                - dist/** # Save build for next steps
          - step:
              name: Deploy
              script:
                - echo "$(ls -la)"
                - echo "$(ls -la dist)"
                - ssh user@your-server rm -rf /var/www/www.your-domain.net/html/your-app
                - scp -r dist/your-app user@your-server:/var/www/your-domain.at/html/your-app
    

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 1970-01-01
      • 2017-06-14
      • 2020-11-20
      • 2017-11-03
      • 1970-01-01
      • 2018-07-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多