@uscreen.de/shipit-deploy-cd
v0.5.9
Published
shipit deploy without git
Downloads
36
Keywords
Readme
shipit-deploy-cd
A shipit deployment task without git requirements.
Task is to just copy some local artefacts to a remote location. This is esp. usefull in Continous-Delivery-Scenarios. And that's why the package appended cd
. It's using rsync
under the hood to only transfer changes and keeps a capristrano like directory structure:
$ tree -L 2
.
├── current -> releases/20190725153703
└── releases
├── 20190623143320
├── 20190723150429
├── 20190724151443
├── 20190725152609
└── 20190725153703
install
a) Install all required packages in one shot:
$ yarn add shipit-cli @uscreen.de/shipit-deploy-cd # or use npm -i
b) Or just add shipit-deploy-cd
to any existing setup:
$ yarn add @uscreen.de/shipit-deploy-cd # or use npm -i
...will yield if shipit-cli
missing
configure
Add some proper task configuration to your shipitfile.js
, example:
// convenience: read app name from it's package.json
const { name } = require('./package.json')
module.exports = shipit => {
// require and instantiate
require('@uscreen.de/shipit-deploy-cd')(shipit)
shipit.initConfig({
// defaults, every env will inherit from here
default: {
dist: 'dist/*', // local source to sync from, can also be an array, like ['public', 'assets']
deployTo: `/<remote>/<path>/<to>/<deploy>/<to>/${name}`,
keepReleases: 5 // we keep a copy of last 5 releases
},
// example stage server (ssh connection settings)
stage: {
servers: '[email protected]'
},
// example live servers (like above but 2 boxes)
live: {
servers: [
'[email protected]',
'[email protected]'
]
}
})
// convenience: register as 'deploy' task
shipit.task('deploy', async () => {
shipit.start('deploy-cd')
})
}
use
As with all other shipit tasks, this one gets invoked by using the shipit-cli
, ie.:
$ shipit stage deploy-cd # or, when registered with another task name
$ shipit stage deploy
Workflow tasks
Following workflow task events are emitted:
- 'deploy'
- 'updated'
- 'published'
- 'cleaned'
- 'deployed'
Tests
For testing we use the package dev-service to run an sshd service we can deploy to.
To use dev-service, you need docker & docker-compose in your PATH (e.g. via Docker Desktop). With direnv dev-service is automatically added to you PATH as long as you reside inside the shipit-deploy-cd folder.
To prepare, copy your public ssh key into services/sshd/authorized_keys/www, e.g. with:
cp ~/.ssh/id_rsa.pub services/sshd/authorized_keys/www
Next adjust the host keys' permissions to be only accessible for the owner:
chmod 600 services/sshd/ssh_keys/*
Now use dev-service to install & start the sshd service:
service install
service start
Before you run the tests first time, you may find it useful to ssh to the service once to confirm the authenticity of the used host:
ssh [email protected] -p 2222
Run the tests by
yarn test
Afterwards, stop the sshd service by
service stop
Roadmap
- add api/config docs