2015-05-12 17:55:54 +03:00
|
|
|
[![Build Status](https://travis-ci.org/stackbuilders/hapistrano.svg?branch=master)](https://travis-ci.org/stackbuilders/hapistrano) [![Hackage version](https://img.shields.io/hackage/v/hapistrano.svg)](http://hackage.haskell.org/package/hapistrano)
|
2014-06-04 20:59:35 +04:00
|
|
|
|
2014-06-04 04:17:20 +04:00
|
|
|
# Hapistrano
|
|
|
|
|
|
|
|
Hapistrano is a deployment library for Haskell applications similar to
|
|
|
|
Ruby's [Capistrano](http://capistranorb.com/).
|
|
|
|
|
|
|
|
## Purpose
|
|
|
|
|
|
|
|
We created Hapistrano because:
|
|
|
|
|
|
|
|
* Deploys should be simple, but as close to atomic as possible (eg,
|
|
|
|
they shouldn't require much application downtime).
|
|
|
|
* Rollback should be trivial to achieve to bring the application back
|
|
|
|
to the last-deployed state.
|
|
|
|
* Deploys shouldn't fail because of dependency problems.
|
|
|
|
|
|
|
|
## How it Works
|
|
|
|
|
|
|
|
Hapistrano (like Capistrano for Ruby) deploys applications to a new
|
|
|
|
directory marked with a timestamp on the remote host. It creates this
|
|
|
|
new directory quickly by placing a git repository for caching purposes
|
|
|
|
on the remote server.
|
|
|
|
|
2017-02-20 17:33:12 +03:00
|
|
|
When the build process completes, it switches a symlink to the `current`
|
|
|
|
release directory, and optionally restarts the web server.
|
2014-06-04 04:17:20 +04:00
|
|
|
|
|
|
|
By default, Hapistrano keeps the last five releases on the target host
|
|
|
|
filesystem and deletes previous releases to avoid filling up the disk.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2017-02-20 17:33:12 +03:00
|
|
|
Hapistrano 0.3.0.0 looks for a configuration file called `hap.yaml` that
|
|
|
|
typically looks like this:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
deploy_path: '/var/projects/my-project'
|
|
|
|
host: myserver.com
|
|
|
|
port: 2222
|
|
|
|
repo: 'https://github.com/stackbuilders/hapistrano.git'
|
|
|
|
revision: origin/master
|
|
|
|
build_script:
|
|
|
|
- stack setup
|
|
|
|
- stack build
|
|
|
|
restart_command: systemd restart my-app-service
|
|
|
|
```
|
|
|
|
|
|
|
|
The following parameters are required:
|
|
|
|
|
|
|
|
* `deploy_path` — the root of the deploy target on the remote host.
|
|
|
|
* `repo` — the origin repository.
|
|
|
|
* `revision` — the SHA1 or branch to deploy. If a branch, you will need to
|
|
|
|
specify it as `origin/branch_name` due to the way that the cache repo is
|
|
|
|
configured.
|
|
|
|
|
|
|
|
The following parameters are *optional*:
|
|
|
|
|
|
|
|
* `host` — the target host, if missing, `localhost` will be assumed (which
|
|
|
|
is useful for testing and playing with `hap` locally).
|
|
|
|
* `port` — SSH port number to use. If missing, 22 will be used.
|
|
|
|
* `build_script` — instructions how to build the application in the form of
|
|
|
|
shell commands.
|
|
|
|
* `restart_command` — if you need to restart a remote web server after a
|
|
|
|
successful rollback, specify the command that you use in this variable. It
|
|
|
|
will be run after both deploy and rollback.
|
|
|
|
|
|
|
|
After creating a configuration file as above, deploying is as simple as:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ hap deploy
|
|
|
|
```
|
|
|
|
|
|
|
|
Rollback is also trivial:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ hap rollback # to rollback to previous successful deploy
|
|
|
|
$ hap rollback -n 2 # go two deploys back in time, etc.
|
|
|
|
```
|
2015-03-13 05:12:35 +03:00
|
|
|
|
2014-06-04 15:25:29 +04:00
|
|
|
# License
|
|
|
|
|
|
|
|
MIT, see [the LICENSE file](LICENSE).
|
2014-06-04 04:17:20 +04:00
|
|
|
|
|
|
|
# Contributing
|
|
|
|
|
|
|
|
Pull requests for modifications to this program are welcome. Fork and
|
|
|
|
open a PR. Feel free to [email me](mailto:justin@stackbuilders.com) if
|
|
|
|
you have questions about what may be accepted before working on a PR.
|
2014-06-04 18:04:41 +04:00
|
|
|
|
|
|
|
If you're looking for a place to start, you may want to check the
|
|
|
|
[open issue](https://github.com/stackbuilders/hapistrano/issues).
|