add vault, consul-template, arvados pkgs
[arvados.git] / services / boot / README.md
1 # arvados-boot
2
3 Coordinates Arvados system services.
4
5 Strategy:
6 * In development, use npm to install JavaScript libraries.
7 * At build time, use webpack on nodejs to compile JavaScript assets.
8 * Deploy with a single Go binary -- no nodejs, no asset files.
9
10 ## dev/build dependencies
11
12 Go:
13
14 ```
15 curl https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz \
16      | sudo tar -C /usr/local -xzf - \
17      && (cd /usr/local/bin && sudo ln -s ../go/bin/* .)
18 ```
19
20 nodejs:
21
22 ```sh
23 curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
24 sudo apt-get install nodejs
25 ```
26
27 ## add/edit static files
28
29 Everything in the `static` directory will be served at `/`.
30
31 ```sh
32 echo foo > static/foo.txt
33 # http://webapp/foo.txt
34 ```
35
36 ## add/edit javascript files
37
38 A webpack will be built using the entry point `js/index.js`, and served at `/js.js`.
39
40 ```sh
41 echo 'function foo() { console.log("foo") }' > js/foo.js
42 echo 'require("./foo"); foo()'               > js/index.js
43 ```
44
45 The default entry point and published location can be changed by editing `webpack.config.js`. For example, to build separate packs from `js/` and `js-admin/` source directories and serve them at `/user.js` and `/admin.js`:
46
47 ```javascript
48 module.exports = {
49     entry: {
50         admin: './js-admin',
51         user: './js'
52     },
53     ...
54 ```
55
56 ## run dev-mode server
57
58 This runs webpack, updates bindata_assetfs.go with the new filesystem, builds a new Go binary, and runs it:
59
60 ```sh
61 npm run dev
62 ```
63
64 To use a port other than the default 8000:
65
66 ```sh
67 PORT=8888 npm run dev
68 ```
69
70 In dev mode, source maps are served, and JS is not minified.
71
72 After changing any source code (including static content), `^C` and run `npm run dev` again.
73
74 ## run tests
75
76 Use nodejs to run JavaScript unit tests in `js/**/*_test.js` (see `js/example_test.js`).
77
78 ```sh
79 npm test
80 ```
81
82 Run Go tests the usual way.
83
84 ```sh
85 go test ./...
86 ```
87
88 ## build production-mode server
89
90 ```sh
91 npm build
92 ```
93
94 The server binary will be installed to `$GOPATH/bin/`.
95
96 ## build & run production-mode server
97
98 ```sh
99 npm start
100 ```