简体   繁体   English

Bitbucket 管道 - 构建 Create-react-app,将其压缩,通过 ftp 上传并在服务器上解压缩

[英]Bitbucket pipeline - build Create-react-app, zip it, upload it via ftp and unzip it on server

I'm using a bitbucket pipeline to deploy my react application.我正在使用 bitbucket 管道来部署我的 React 应用程序。

Right now my pipeline looks like this:现在我的管道看起来像这样:

image: node:10.15.3

pipelines:
  default:
      - step:
          name: Build
          script:
          - npm cache clean --force
          - rm -rf node_modules
          - npm install
          - CI=false npm run deploy-app
          artifacts: # defining build/ as an artifact
          - 'build-artifact/**'
      - step:
          name: Deploy
          script:
            - apt-get update
            - apt-get install ncftp
            - ncftpput -v -u "$USERNAME" -p "$PASSWORD" -R $SERVER build 'build-artifact/*'
            - echo Finished uploading build

It works really well like this, but the ftp upload takes about 8 minutes, which is way to long because with the free plan of Bitbucket I can only use the pipeline feature for 50 minutes per month.它像这样工作得很好,但是 ftp 上传大约需要 8 分钟,这太长了,因为使用 Bitbucket 的免费计划,我每个月只能使用管道功能 50 分钟。

It seems like the uploads of every small file takes forever.似乎每个小文件的上传都需要很长时间。 That's why I thought that maybe uploading a single zip file will be way more performant.这就是为什么我认为上传单个 zip 文件可能会更高效的原因。

So my question is: Is it really faster?所以我的问题是:它真的更快吗? And how it is possible to ZIP the artifact, upload the zip to the server and unzip it there?以及如何压缩工件,将 zip 上传到服务器并在那里解压缩?

Thanks for your help谢谢你的帮助

In fact, you should consider using another tool to upload file, for example rsync which has a couple of useful features, such as compression of the data.实际上,您应该考虑使用其他工具来上传文件,例如rsync ,它具有一些有用的功能,例如数据压缩。 It also only uploads files that were changed from the previous upload, which is gonna speed up the uploads as well.它还只上传从上次上传更改过的文件,这也会加快上传速度。 You can use the rsync-deploy pipe for example:例如,您可以使用rsync-deploy管道:

script:
  - pipe: atlassian/rsync-deploy:0.3.2
    variables:
      USER: 'ec2-user'
      SERVER: '127.0.0.1'
      REMOTE_PATH: '/var/www/build/'
      LOCAL_PATH: 'build'
      EXTRA_ARGS: '-z'

Note the -z option passed via the EXTRA_ARGS.注意通过 EXTRA_ARGS 传递的-z选项。 This will enable the data compression when transferring files.这将在传输文件时启用数据压缩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM