Documentation ¶
Overview ¶
Package ghdeploy provides an opinionated deployment process using GitHub & systemd.
It is meant for single instance web servers, and not useful if you're running a fleet of web servers.
Requirements ¶
• You are using a blue/green deployment strategy. This essentially means you will have some server in the front (haproxy, caddy, nginx etc) that will choose between the blue or the green instance, whichever is available.
• You are using Github releases. It is expected the release upload a single file, which should be a tarball.
• You are using systemd units to run your service. This should be a template unit, so the same unit is used for the blue and green instances.
Procedure ¶
• See example repo for how this should be setup.
• Configure your Github webook to hit the endpoint you have configured.
• Configure your Github webook and the deployer with the hook secret.
Index ¶
- type Deployer
- type Option
- func EmailClient(client *mail.Dialer) Option
- func EmailFrom(addr string) Option
- func EmailTo(addr string) Option
- func EnableDirectHandler(enable bool) Option
- func GithubAccount(account string) Option
- func GithubHookSecret(secret string) Option
- func GithubRepo(repo string) Option
- func GithubToken(token string) Option
- func HealthCheckPath(path string) Option
- func HealthCheckProtocol(protocol string) Option
- func HealthCheckTimeout(timeout time.Duration) Option
- func PortBlue(port int) Option
- func PortGreen(port int) Option
- func ReleasesDir(dir string) Option
- func SystemdServiceName(name string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deployer ¶
type Deployer struct {
// contains filtered or unexported fields
}
Deployer handles deployment of new releases.
type Option ¶
type Option func(*Deployer)
Option configures the Deployer.
func EmailClient ¶
EmailClient configures the email client used to send success or failure emails on deployment.
func EnableDirectHandler ¶
EnableDirectHandler enables a second handler under the path /direct/ that accepts a POST request with a `release_tag` parameter and triggers the deploy process. This is disabled by default, as it is an insecure endpoint. You may enable this at your discretion.
This can be handy to quickly deploy a different release, and can be invoked as such:
curl http://myapp.com/webhook/github/direct/ -F release_tag=v42
func GithubAccount ¶
GithubAccount configures the Github account.
func GithubHookSecret ¶
GithubHookSecret provides the hook secret, if one is set. Leaving this blank will disable hook validation.
func HealthCheckPath ¶
HealthCheckPath configures the health check path. The default is /.
func HealthCheckProtocol ¶
HealthCheckProtocol must be one of tcp, http or https. The default is tcp, which simply checks for a successful connection. HTTP checks for a 200 response on the configured path.
func HealthCheckTimeout ¶
HealthCheckTimeout specifies the duration we wait to check if a new service is healthy. The default is 30s.
func ReleasesDir ¶
ReleasesDir is where the last two releases will be stored. The default is ~/.local/<service-name>.
func SystemdServiceName ¶
SystemdServiceName configures the base name of the unit. Defaults to GithubRepoName. It is expected this will be a template unit. See package documentation for more.