-
Notifications
You must be signed in to change notification settings - Fork 63
Add build with docker docs #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ``` |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| --- | ||
| 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 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.