|
| 1 | +# Sanitarium.io |
| 2 | + |
| 3 | +[TOC] |
| 4 | + |
| 5 | +## Outline |
| 6 | + |
| 7 | +Welcome to Sanitarium.io, a facility for holding the criminally insane. Our archive exposes a JSON API, enabling you to query hand-curated data on horror movie antagonists. |
| 8 | + |
| 9 | +Patient records contain an in-depth profile and previous criminal activity, including a list of known victims. Our facility basement is used to house our aquatic killers. |
| 10 | + |
| 11 | +### Go Commands |
| 12 | + |
| 13 | +#### Install |
| 14 | + |
| 15 | +**Installer:** *https://dl.google.com/go/go1.11.4.darwin-amd64.pkg* |
| 16 | + |
| 17 | +**Workspace:** /Users/stephencathcart/go/src |
| 18 | + |
| 19 | +##### Update PATH |
| 20 | + |
| 21 | +``` |
| 22 | +# /Users/stephencathcart/.bash_profile |
| 23 | +export GOPATH=$HOME/go |
| 24 | +export PATH=$GOPATH/bin:$PATH |
| 25 | +``` |
| 26 | + |
| 27 | +#### Packages |
| 28 | + |
| 29 | +``` |
| 30 | +# Install vendor |
| 31 | +go get -u github.com/kardianos/govendor |
| 32 | +
|
| 33 | +# Install packages |
| 34 | +govendor sync |
| 35 | +
|
| 36 | +# Ensure build installs to bin |
| 37 | +go install |
| 38 | +``` |
| 39 | + |
| 40 | +#### Format |
| 41 | + |
| 42 | +``` |
| 43 | +cd {workspace} |
| 44 | +go fmt ./... |
| 45 | +``` |
| 46 | +Which will format all code in current directory and all of its subdirectories. |
| 47 | + |
| 48 | +#### Test |
| 49 | + |
| 50 | +``` |
| 51 | +cd {workspace} |
| 52 | +go test ./... |
| 53 | +``` |
| 54 | +Which will run all tests in current directory and all of its subdirectories. |
| 55 | + |
| 56 | +#### Build & Run |
| 57 | + |
| 58 | +Environment variables: |
| 59 | + |
| 60 | +- **PORT:** Set port number for local development. Heroku supplies a dynamic port. |
| 61 | +- **ENV:** Set to *DEV* for local development. Used to configure *api* subdomain host. |
| 62 | + |
| 63 | +``` |
| 64 | +cd {workspace} |
| 65 | +PORT=8000 ENV=DEV go run main.go |
| 66 | +``` |
| 67 | +Which will run the application. |
| 68 | + |
| 69 | +### Localhost Access |
| 70 | + |
| 71 | +**Frontend:** *http://lvh.me:8000* |
| 72 | + |
| 73 | +**API:** *http://api.lvh.me:8000/killers/random* |
| 74 | + |
| 75 | +### Heroku Setup |
| 76 | + |
| 77 | +**User:** *[HIDDEN]* |
| 78 | + |
| 79 | +#### Install Heroku CLI (requires Git) |
| 80 | + |
| 81 | +**Installer:** *https://cli-assets.heroku.com/heroku.pkg* |
| 82 | + |
| 83 | +#### Heroku CLI Commands |
| 84 | + |
| 85 | +##### Verify Installation |
| 86 | + |
| 87 | +``` |
| 88 | +heroku --version |
| 89 | +``` |
| 90 | + |
| 91 | +##### Login |
| 92 | + |
| 93 | +``` |
| 94 | +heroku login |
| 95 | +``` |
| 96 | + |
| 97 | +##### Create EU Dyno with Go Buildpack |
| 98 | + |
| 99 | +``` |
| 100 | +heroku create sanitarium --region eu --buildpack heroku/go |
| 101 | +``` |
| 102 | + |
| 103 | +##### Create Domains |
| 104 | +``` |
| 105 | +heroku domains:add sanitarium.io --app sanitarium |
| 106 | +heroku domains:add www.sanitarium.io --app sanitarium |
| 107 | +heroku domains:add api.sanitarium.io --app sanitarium |
| 108 | +``` |
| 109 | + |
| 110 | +##### List Hosts |
| 111 | +``` |
| 112 | +host sanitarium.io |
| 113 | +host www.sanitarium.io |
| 114 | +``` |
| 115 | + |
| 116 | +##### Deploy |
| 117 | +``` |
| 118 | +git push https://heroku:{api-key}@git.heroku.com/sanitarium.git HEAD |
| 119 | +``` |
| 120 | + |
| 121 | +### Cloudflare |
| 122 | + |
| 123 | +**User:** *[HIDDEN]* |
| 124 | + |
| 125 | +**SSL:** Flexible |
| 126 | + |
| 127 | +**Universal SSL Status:** Active Certificate |
| 128 | + |
| 129 | +#### Manage DNS settings |
| 130 | + |
| 131 | +| Type | Name | *Value | TTL | |
| 132 | +|------ | ------------- | --------------------------------------- | ------------- | |
| 133 | +| CNAME | api | [HIDDEN] | Automatic | |
| 134 | +| CNAME | sanitarium.io | [HIDDEN] | Automatic | |
| 135 | +| CNAME | www | [HIDDEN] | Automatic | |
| 136 | +| MX | sanitarium.io | [HIDDEN], priority: 10 | 1h | |
| 137 | +| MX | sanitarium.io | [HIDDEN], priority: 10 | 1h | |
| 138 | +| MX | sanitarium.io | [HIDDEN], priority: 5 | 1h | |
| 139 | +| MX | sanitarium.io | [HIDDEN], priority: 5 | 1h | |
| 140 | +| MX | sanitarium.io | [HIDDEN], priority: 1 | 1h | |
| 141 | +| TXT | sanitarium.io | [HIDDEN] | Automatic | |
| 142 | + |
| 143 | +> **Note:** CNAME values are dynamically generated by Heroku when a new domain is added. |
| 144 | +
|
| 145 | +#### Configure Page Rules |
| 146 | + |
| 147 | +| Rule | URL Match | Type | Sub Type | Value | |
| 148 | +|------ | ----------------------- | ---------------- | ------------------------ | -------------------- | |
| 149 | +| 1 | *www.sanitarium.io/ | Forwarding URL | 301 - Permanent Redirect | http://sanitarium.io | |
| 150 | +| 2 | http://*sanitarium.io/* | Always Use HTTPS | ... | ... | |
| 151 | + |
| 152 | +### Domain Registrar |
| 153 | + |
| 154 | +**Registrar:** name.com |
| 155 | + |
| 156 | +**User:** *[HIDDEN]* |
| 157 | + |
| 158 | +#### Configure Nameservers |
| 159 | + |
| 160 | +| Nameserver | |
| 161 | +|--------------- | |
| 162 | +| [HIDDEN] | |
| 163 | +| [HIDDEN] | |
| 164 | + |
| 165 | +### Bitbucket CI/CD Pipeline |
| 166 | + |
| 167 | +**Enable Pipelines:** true |
| 168 | + |
| 169 | +Commiting to *master* will automatically deploy to Heroku. |
| 170 | + |
| 171 | +#### Repository Variables |
| 172 | + |
| 173 | +| Names | Value | |
| 174 | +|---------------- | ---------- | |
| 175 | +| HEROKU_API_KEY | *** | |
| 176 | +| HEROKU_APP_NAME | sanitarium | |
| 177 | + |
| 178 | +### Mailchimp |
| 179 | + |
| 180 | +**User:** *[HIDDEN]* |
| 181 | + |
| 182 | +**Email:** *[HIDDEN]* |
| 183 | + |
| 184 | +### GSuite |
| 185 | + |
| 186 | +**User:** *[HIDDEN]* |
0 commit comments