Skip to content

Commit c48f03f

Browse files
jkowalskiJulio López
authored andcommitted
readme: added build architecture doc
The slide was generated using Google Slides and the source is public at: https://docs.google.com/presentation/d/1VhsANHnV5vs4vCmjVTFlMpDgDUBNtyU9Ex04EX0wNRI/edit?usp=sharing If you need to modify it, please request permissions.
1 parent f9db94c commit c48f03f

File tree

5 files changed

+134
-2
lines changed

5 files changed

+134
-2
lines changed

BUILD.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Kopia Build Architecture
2+
3+
![Kopia](icons/kopia.svg)
4+
5+
Kopia build pipeline is set up to generate the following artifacts:
6+
7+
* Standalone `kopia` executable for all supported platforms, optionally with embedded graphical UI
8+
* KopiaUI - desktop app for all supported platforms: Windows, macOS, and Linux
9+
* The static content of [kopia.io](https://kopia.io) website
10+
11+
Kopia build is based on `Makefile` and provides the following main targets:
12+
13+
* `$ make install` - builds full `kopia` command-line executable that also embeds graphical UI components that can be used in a browser. The output is stored in `$HOME/go/bin/kopia`
14+
15+
* `$ make install-noui` - builds simplified `kopia` executable without embedded graphical UI. The output is stored in `$HOME/go/bin/kopia`
16+
17+
* `$ make install` - builds desktop application based on [Electron](https://electronjs.org) using [Electron Builder](https://electron.build) The output is stored in the `dist/kopia-ui` subdirectory
18+
19+
* `$ make website` - builds [kopia.io](https://kopia.io) website using [Hugo](https://gohugo.io). The output is stored in `site/public` and published to [Github Pages](https://github.com/kopia/kopia.github.io) from [Travis CI](https://travis-ci.org/kopia/kopia) on each build.
20+
21+
The project structure is also compatible with `go get`, so getting the latest Kopia command line tool (albeit without any UI functionality) is as simple as:
22+
23+
```
24+
$ go get github.com/kopia/kopia
25+
```
26+
27+
## Build Pipeline Overview
28+
29+
The following picture provides high-level overview of the build pipeline.
30+
31+
![Build Architecture](build_architecture.svg)
32+
33+
## HTML UI
34+
35+
THe HTML UI builds HTML-based user interface that is embedded in Kopia binary by using [go-bindata](github.com/go-bindata/go-bindata).
36+
37+
The UI is build using [React](https://reactjs.org) and more specifically [Create React App](https://reactjs.org/docs/create-a-new-react-app.html#create-react-app) toolchain.
38+
39+
When developing the UI, the most convenient way is to use two terminals. The first terminal runs `kopia server` without the UI. The second one runs development server of React with hot-reload, so changes are immediately reflected in the browser.
40+
41+
In the first terminal do:
42+
43+
```shell
44+
$ make install-noui && $HOME/go/bin/kopia server
45+
```
46+
47+
In the second terminal do:
48+
49+
```shell
50+
$ make -C htmlui dev
51+
```
52+
53+
This will automatically open the browser with the UI page on http://localhost:3000. Changing any file under `htmlui/` will cause the browser to hot-reload the change. In most cases, the changes to the kopia server don't even require reloading the browser.
54+
55+
To make sure HTML pages compile correctly use:
56+
57+
```shell
58+
$ make -C htmlui build-html
59+
```
60+
61+
To convert generated HTML to embedded go source code use:
62+
63+
```shell
64+
$ make html-ui-bindata
65+
```
66+
67+
To manually build the `kopia` binary with the embedded HTML that was just generated in the previous step:
68+
69+
```shell
70+
$ go install -tags embedhtml
71+
```
72+
or
73+
```shell
74+
$ make install
75+
```
76+
77+
When compiling Go code without `embedhtml` build tag, the embedded UI will be just a placeholder. This is equivalent to:
78+
79+
```shell
80+
$ make install-noui
81+
```
82+
83+
## KopiaUI App
84+
85+
KopiaUI is built using [Electron](https://electronjs.org) and packaged as native binary using [Electron Builder](https://electron.build). The app is just a shell that invokes `kopia server --ui` and connects the browser to it, plus it provides native system tray integration. Kopia executable is embedded as a resource inside KopiaUI app, to simplify usage.
86+
87+
To build the app:
88+
89+
```shell
90+
$ make kopia-ui
91+
```
92+
93+
The generated app will be in:
94+
95+
* `dist/kopia-ui/win-unpacked` on Windows
96+
* `dist/kopia-ui/mac/KopiaUI.app` - on macOS
97+
* `dist/kopia-ui/linux-unpacked` on Linux
98+
99+
When developing the app shell it is convenient to simply run Electron directly on the source code without building.
100+
101+
```shell
102+
$ make -C app dev
103+
```
104+
105+
>NOTE: this also opens the browser window due to CRA development server, but it can be safely disregarded. Because KopiaUI configuration pages are built using CRA, they also benefit from hot-reload while developing this way.
106+
107+
## Website
108+
109+
The [kopia.io](https://kopia.io) website is built using [Hugo](https://gohugo.io).
110+
111+
To build the website use:
112+
113+
```shell
114+
$ make -C site build
115+
```
116+
117+
This will auto-generate [Markdown](https://en.wikipedia.org/wiki/Markdown) files with documentation for currently supported Kopia CLI subcommands and store them under `site/content/docs/Reference/Command-Line` and then generate the website which is stored in `site/public`.
118+
119+
To see the website in a browser it's more convenient to use:
120+
121+
```shell
122+
$ make -C site server
123+
```
124+
125+
This starts a server on http://localhost:1313 where the website can be browsed.
126+

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Getting Started
3030
---
3131
See [Documentation](https://kopia.io/docs/) for more information.
3232

33+
Building Kopia
34+
---
35+
See [Build Infrastructure](BUILD.md) for more information on building Kopia and working with the source code.
36+
3337
Licensing
3438
---
3539
Kopia is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.

build_architecture.svg

Lines changed: 1 addition & 0 deletions
Loading

htmlui/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ include ../tools/tools.mk
55
dev: node_modules
66
$(npm) $(npm_flags) run start
77

8+
# build HTML, run in CI mode which is more strict
89
build-html: node_modules
9-
$(npm) $(npm_flags) run build
10+
CI=true $(npm) $(npm_flags) run build
1011

1112
node_modules: $(npm)
1213
$(npm) $(npm_flags) install

site/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# don't put tools under current directory, otherwise 'make server' fails because there are too
22
# many open files due to 'node_modules'
3-
WATCH=true
3+
WATCH=false
44

55
all: build
66

0 commit comments

Comments
 (0)