Supercharge your ftp deployments with fast-ftp.
Uploading guestbell.com - ~500 files, 27 directories some 5 levels deep
Time taken | Improvement | |
---|---|---|
basic-ftp | 217sec | 10x |
ftp-deploy | 197sec | 9x |
fast-ftp | 22sec | 1x |
Ftp doesn't support parallel operations on a single connections. But you can usually spawn many connections. fast-ftp does that + leverages optimized algorithms to increase speed of common tasks like uploading whole directories, deleting whole directories etc.
Fast ftp was made to accelerate uploading static sites - 1 directory with many files (we also expose api for custom use-cases). We also want the site to work during deployment - to not enter a broken state. How can that happen? If you first delete the whole site and then start uploading or simply just sync directories. Both of these can lead to broken sites if user navigates to it at a wrong moment.
- Directory is first uploaded to temp ftp directory
- Site directory is renamed to old ftp directory
- Temp ftp directory is renamed to site directory
This way the downtime is close to 0 and there's not risk of broken sites.
- Installation:
npm @guestbell/fast-ftp
# or
yarn @guestbell/fast-ftp
- Config Ftp Client
Fast-ftp reads ftp client config (sensitive) from environment variables.
These are required: FTP_HOST FTP_USERNAME FTP_PASSWORD These are optional: FTP_PORT FTP_SECURE
We also support deploy.env config file. Sample follows:
FTP_HOST=example.com
FTP_USERNAME=johndoe
FTP_PASSWORD=secret
- Config deployment script
This is done by command line parameters:
These are required: --remote-root Directory path on ftp --local-root Directory path on local machine These are optional: --tmp-root Temporary directory path on ftp - defaults to 'remote-root'+'-tmp' --old-root Old directory path on ftp - defaults to 'remote-root'+'-old' --concurrency How many connections to spawn
- Run the script
fast-ftp --remote-root=/sub/example --local-root=/path-to-published
We provide accelerated ftp functions and helpers you can use in your pipeline or node-js projects.
General idea is you first use getClients function to obtain an array of ftp-clients (connections). These are then passed to other functions. Check the main deployment script as an example.
Full api docs here
- GuestBell - Customer centric online POS for Hotels and short terms stays.
- Fork it
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
MIT