Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
id: build
title: Build Gotify
---

1. [Setup development environment](dev-setup.md)

1. Build the UI

```bash
$ (cd ui && npm run build)
```

1. Generate static assets for go.

Run [packr](https://github.com/gobuffalo/packr) (embeds static assets in go binaries)

```bash
$ packr
```

1. Build the Go Binary

It is recommended to build gotify/server via the [gotify/build docker images](https://github.com/gotify/build),
this ensures that [plugins](plugin.md) will be compatible with the built binary (because the same build environment is used).

Set the LD_FLAGS with meta information like the version or the commit:

```bash
$ export LD_FLAGS="-w -s -X main.Version=$(git describe --tags | cut -c 2-) -X main.BuildDate=$(date "+%F-%T") -X main.Commit=$(git rev-parse --verify HEAD) -X main.Mode=prod";
```

Execute [gotify/server Makefile](https://github.com/gotify/server/blob/master/Makefile) tasks to build gotify/server.

```bash
# builds all supported platforms
$ make build
# builds a specific platform
$ make build-linux-amd64
$ make build-linux-arm-7
$ make build-linux-arm64
$ make build-windows-amd64
```

If you do not want to use the docker images you can build gotify/server like this:

```bash
$ go build -ldflags="$LD_FLAGS" -o gotify-server
```

_The project has a CGO reference (because of sqlite3), therefore a CGO cross compiler is needed for compiling for
other platforms (the gotify/build docker images already contain the needed cross compilers)._

```bash
$ CGO_ENABLED=1 CC=${CROSS_GCC} CXX=${CROSS_G++} GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} \
go build -ldflags="$LD_FLAGS" -o gotify-server
```
140 changes: 0 additions & 140 deletions docs/dev-environment.md

This file was deleted.

86 changes: 86 additions & 0 deletions docs/dev-server-and-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
Comment thread
jmattheis marked this conversation as resolved.
id: dev-server-and-tests
title: Servers and Tests
---

## Start development servers

### Backend

Start the server in development mode.

```bash
$ go run .
```

### UI

Start the UI development server.

_Commands must be executed inside the ui directory._

```bash
$ npm start
```

Open `http://localhost:3000` inside your favorite browser.

The UI requires a Gotify server running on `localhost:80`. This can be adjusted inside
[ui/src/index.tsx](https://github.com/gotify/server/blob/master/ui/src/index.tsx).

## Update Swagger spec

The [gotify/server REST-API](swagger-docs.md) is documented via Swagger. The Swagger definition is generated via source code comments
([example comment](https://github.com/gotify/server/blob/09c1516a170dfb47d29644db622655b540b94922/api/application.go#L33)).

After changing such a source code comment, you can run the following command to update the Swagger definition.

```bash
$ make update-swagger
```

## Tests

### Execute Backend Tests

#### Run tests with parallelism

```bash
$ go test ./...
```

#### Run Tests with Coverage

```bash
$ make test-coverage
$ go tool cover -html=coverage.txt # get a HTML coverage report
```

#### Run Tests with Race Detector

```bash
$ make test-race
```

### Execute UI (end2end) Tests

Build the ui because the end2end test should be run against the production build.
(This needs to be done on every change in the UI)

```bash
$ (cd ui && npm run build)
```

Now execute the tests with npm

```bash
$ (cd ui && npm run test)
```

### Execute Static Checks

The following command checks the formatting and executes some linters like tslint and govet.

```bash
$ make check
```
42 changes: 42 additions & 0 deletions docs/dev-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
id: dev-setup
title: Setup Environment
---

Gotify requires:

- Go 1.11+
- Node 11.x

## Clone sources

Clone gotify server source from git:

```bash
$ git clone https://github.com/gotify/server.git && cd server
```

## Setup Backend

If you are in GOPATH, enable [go modules](https://github.com/golang/go/wiki/Modules) explicitly:

```bash
$ export GO111MODULE=on
```

Download dependencies

```bash
$ make download-tools
$ go get -d
```

## Setup UI

_Commands must be executed inside the ui directory._

Download dependencies with [npm](https://github.com/npm/npm).

```bash
$ npm install
```
7 changes: 3 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ In this example the directory is mounted to `/var/gotify/data` this directory sh

## Binary

In this tutorial we set up gotify/server v1.2.1 on a 64 bit linux server but it should be similar on other platforms.
In this tutorial we set up gotify/server v2.0.0 on a 64 bit linux server but it should be similar on other platforms.

Download the zip with the binary for your platform from [gotify/server Releases](https://github.com/gotify/server/releases).

```bash
$ wget https://github.com/gotify/server/releases/download/v1.2.1/gotify-linux-amd64.zip
$ wget https://github.com/gotify/server/releases/download/v2.0.0/gotify-linux-amd64.zip
```

Unzip the archive.
Expand All @@ -54,5 +54,4 @@ $ sudo ./gotify-linux-amd

## Source

1. [Setup](dev-environment.md#setup) the dev environment.
2. [Build](dev-environment.md#building-releases) a production release.
See [build](build.md).
Loading