la-haute-societe / ssh-deploy-release Goto Github PK
View Code? Open in Web Editor NEWDeploy releases over SSH with rsync, archive ZIP / TAR, symlinks, SCP ...
Home Page: https://www.npmjs.com/package/ssh-deploy-release
License: MIT License
Deploy releases over SSH with rsync, archive ZIP / TAR, symlinks, SCP ...
Home Page: https://www.npmjs.com/package/ssh-deploy-release
License: MIT License
deployator rollback
Is it possible to make option.exclude work?
This is what I have done :
const Deployer = require('ssh-deploy-release');
const options = {
localPath: '/Users/joe/workspace/codex/',
host: 'my-server',
port: '9222',
username: 'joe',
password: 'joe*',
deployPath: '/var/lib/codex/',
currentReleaseLink: 'htdocs',
exclude : ['/.svn']
};
const deployer = new Deployer(options);
deployer.deployRelease(() => {
console.log('Ok !')
});
There is a directory located in /Users/joe/workspace/codex/.svn.
I don't want this directory to be in my release.
Unfortunately, the configuration doesn't work.
When I execute yarn deployator deploy --environment=review --branch="master" --debug
I get this error :
Compress release
Error while compressing
/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:147
throw err;
^
Error: size mismatch
at Sink.<anonymous> (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/pack.js:174:23)
at Sink.f (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/once/once.js:25:25)
at Sink.onfinish (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/end-of-stream/index.js:31:27)
at Sink.emit (events.js:215:7)
at finishMaybe (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:620:14)
at endWritable (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:629:3)
at Sink.Writable.end (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:567:22)
at Readable.onend (/Users/guillaume.c/Documents/projets/zicplace/marketplace/workspace/node_modules/readable-stream/lib/_stream_readable.js:577:10)
at Object.onceWrapper (events.js:299:28)
at Readable.emit (events.js:215:7)
error Command failed with exit code 1.
Here is my config file :
"use strict";
module.exports = function (options) {
return {
common: {
localPath: process.cwd(),
share: {},
exclude: [
'.git'
],
create: [],
makeWritable: [
'composer.json',
'composer.lock',
'vendor',
'web',
],
debug: true,
},
environments: {
review: {
host: 'myhost.com',
username: 'username',
password: 'pwd',
deployPath: '/my/path/' + options.get('branch'),
allowRemove: true
},
}
};
};
Thanks
In order to be able to test seriously, we need a test SFTP server. We can use the atmoz/sftp image to set up an SFTP server accepting connections authenticated using password or private keys.
This would be the first step towards having real, reliable e2E tests.
zip format:
archiver('zip', { zlib: { level: 9 } }
tar.gz format:
archiver('tar', { gzip: true, gzipOptions: { level: 9 } }
By default, user-supplied commands executed on the server are run in the user's home directory.
It would make more sense to execute them in deployPath
or the release.path
.
scp2 hasn't been updated in 3 years and most probably won't be anytime soon since there is currently no maintainer.
This causes 2 dependency problems:
It's less than 500 lines of code so we could include it in ssh-deploy-release.
This would allow us to fix #14.
Hello,
The option releasesToKeep seems not to be seen by the tool.
const Deployer = require('ssh-deploy-release');
const options = {
localPath: '/Users/joe/codex/',
host: 'joe.com',
port: '9222',
username: 'joe',
password: 'mypwd',
allowRemove: true,
releasesToKeep: 5,
deployPath: '/var/lib/www/codex/',
currentReleaseLink: 'htdocs',
exclude : ['.svn/**']
};
const deployer = new Deployer(options);
deployer.deployRelease(() => {
console.log('Ok !')
});
The releases are well deployed but none of the releases are removed ever.
Do I need to use removeRelease explicitly? In that case, what is the purpose of allowRemove and releasesToKeep ?
Connect to .com
Connected
Compress release
Archive created : 5.23 MB
Create release folder on remote
Remote command : mkdir -p /var/www/releases//2017-06-13-00-50-43-443-UTC
chmod ugo+w /var/www/releases//2017-06-13-00-50-43-443-UTC
Done
Upload archive to remote
⠸ Uploadingbuffer.js:262
throw new TypeError(kFromErrorMsg);
^
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
at fromObject (buffer.js:262:9)
at Function.Buffer.from (buffer.js:101:10)
at new Buffer (buffer.js:80:17)
at onNEWKEYS (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Connection.js:2282:29)
at Parser. (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Connection.js:123:5)
at emitNone (events.js:86:13)
at Parser.emit (events.js:185:7)
at Parser.parsePacket (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Parser.js:468:12)
at Parser.execute (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Parser.js:249:14)
at Socket. (/Users/.../.../node_modules/scp2/node_modules/ssh2/lib/Connection.js:523:18)
From the readme:
#### options.archiveType
`zip` : Use *zip* compression (`unzip` command on remote)
`tar` : Use *tar gz* compression (`tar` command on remote)
Default : `tar`
The archive has a .tar.gz
extension but it is not actually compressed.
I think the problem is at https://github.com/la-haute-societe/ssh-deploy-release/blob/master/src/Archiver.js#L33.
The archiver option is always an empty object.
I'm guessing there were some plans to wire in the gzip option specified here: https://github.com/la-haute-societe/ssh-deploy-release/blob/master/src/Options.js#L22
The decompressArchiveOnRemoteTask does not work on my configuration. The "cd " + this.release.path command doesn't work so any of the following commands are performed on the root shell login. When I modify your code to use absolute paths for the untarring, just like you do with the rm, it's working perfectly.
The server I am deploying to is an ubuntu 16.04. Maybe it is OS specific.
I tried to use the upload.remote
function to upload a .env
-file from my local pc to the target directory at the server.
The .env-File is placed in ../private
from the perspective of the working directory, where the deploy-script was started /backend
.
Nevertheless what I try, I got "Error: No such File".
I've did some debuging, and figured out, that the implementation of upload.remote
was logical wrong:
This piece of code shows, that the src is always added to the server-target path.
This fully breaks the functionality, if your src
is not equal to a single filename without any path.
Example:
$src = '/home/me/private/myFileToUpload.txt';
$target = '/var/www/serverRoot/';
sftp.fastPut(src, `${target}/${src}`
Will try to upload the file to:
/var/www/serverRoot//home/me/private/myFileToUpload.txt
preproduction: {
localPath: 'www',
host: 'xxx.xxx.xxx.xxx',
port: 2201,
username: 'root',
password: 'xxxxxxxx',
deployPath: '/srv/www/preprod',
},
Trying to deploy using this example config fails with the following error message:
Fatal error : Error: Command failed: rsync --rsh='sshpass -p "xxxxxxxx" ssh -l root -o StrictHostKeyChecking=no' -a --stats --delete www/ [email protected]:/srv/www/preprod/synchronized
ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
I cant find in the documentation any about how to load / use the config file with npm script?
I install it with npm install ssh-deploy-release --save
then i add npm run ssh-deploy-release
? but how i tell him what configs he have to use?
There is a later version on npm than is tagged on github.
I try to run my deploy-script, but got this error:
> DEPLOY_TYPE=production node scripts/deployment.cjs
start deployment.cjs
/home/me/myProject/node_modules/cli-progress/lib/formatter.js:1
const _stringWidth = require('string-width');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/me/myProject/node_modules/string-width/index.js from /home/me/myProject/node_modules/cli-progress/lib/formatter.js not supported.
Instead change the require of index.js in /home/me/myProject/node_modules/cli-progress/lib/formatter.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/lib/formatter.js:1:22)
at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/lib/generic-bar.js:3:20)
at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/lib/single-bar.js:1:21)
at Object.<anonymous> (/home/me/myProject/node_modules/cli-progress/cli-progress.js:1:20)
at Object.<anonymous> (/home/me/myProject/node_modules/ssh-deploy-release/dist/Remote.js:19:21)
at Object.<anonymous> (/home/me/myProject/node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:15:16)
at Object.<anonymous> (/home/me/myProject/scripts/deployment.cjs:3:18) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v18.16.0
As you see in the above output, the error appears right before the second console.log, so the issue must be on ssh-deploy-release and it's dependencies.
-p
switch in mkdir is not recognised in windowsMb add some progress bar when upload is in progress? It take too long and I am not sure is it stuck or working. Also I notice that upload speed is lower then usual (for example when I use other SFTP client).
Add a compression
option to enable the rsync -z
flag when in synchronize mode.
The default value could be true
to speed up builds and false
could be passed to make it work on server not supporting compression.
There is a kind of serious bug while using mode "synchronize",
at first the deployment fails, but it also creates a file in the directory with the characters from the command, including also the password:
I think it is caused because the password is wrapped with single quote, that will break the open single quote at --rsh
Using mode "archive" works like a charm.
Requiring another way to set excludes for synchronize mode (rsync) is error prone.
The rsync command has an --exclude
switch that can be called several times to exclude different files and folders :
rsync -a --exclude media --exclude storage/ --exclude some/deep/directory
This works for files & directories, so we could just build a list of --exclude
switches from the
exclude
option form the configuration.
The only pitfall is that it doesn't support the glob syntax: --exclude craft/storage/**
or --exclude craft/storage/*
doesn't work, you have to use either --exclude craft/storage/
or --exclude craft/storage
. To avoid headaches we should advise in the exclude
option documentation to use both the glob and the rsync syntax to exclude a directory:
{
...
exclude: [
'craft/storage/**', // Glob syntax
'craft/storage/', // rsync syntax
],
...
}
Another option would be to rewrite the excludes written in glob syntax when using the synchronize mode but it seems like a bad idea.
It's not the same as onBeforeLink
which is called before creating symlinks for shared elements.
This one should be called right before replacing the current release symlink (just before this line).
It would allow the user to execute actions (ex: fine tuning permissions) once the release has been fully assembled but before it goes live so that when it does, it's fully functional right away.
Currently, publishing to the NPM registry is a manual operation.
This should be automated so that the package is published automatically on each tag push.
Present in 3.0.0-beta.7.
node_modules/any-shell-escape/shell-escape.js:31
stringOrArray.forEach(function(member) {
^
TypeError: Cannot read property 'forEach' of undefined
at module.exports (node_modules/any-shell-escape/shell-escape.js:31:19)
at module.exports.synchronize (node_modules/ssh-deploy-release/dist/Remote.js:168:35)
at module.exports.uploadReleaseTask (node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:233:17)
at eachfn (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:2952:28)
at replenish (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:444:21)
at iterateeCallback (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:428:21)
at node_modules/ssh-deploy-release/node_modules/async/dist/async.js:325:20
at result (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:2957:17)
at remote.createFolder (node_modules/ssh-deploy-release/dist/ssh-deploy-release.js:191:7)
at wrapper (node_modules/ssh-deploy-release/node_modules/async/dist/async.js:272:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I don't know if this is expected behavior but the whole script breaks when standard message (not error or warning) comes from the command inside onAfterDeploy. My solution right now is to put a 2>/dev/null || true
after yeach command, so that the process don't break without reason.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.