2021-12-02 05:08:12 +01:00
# Building
2022-03-17 03:33:23 +01:00
!!! info
These instructions are pretty rough. My apologies for that. Please help improve them my letting me
know in a [GitHub issue ](https://github.com/binwiederhier/ntfy/issues ).
2021-12-02 05:08:12 +01:00
## ntfy server
2022-03-17 03:33:23 +01:00
The ntfy server source code is available [on GitHub ](https://github.com/binwiederhier/ntfy ). The codebase for the
server consists of three components:
* **The main server and API** is written in [Go ](https://go.dev/ ) (so you'll need Go). Its main entrypoint is at
[main.go ](https://github.com/binwiederhier/ntfy/blob/main/main.go ), and the meat you're likely interested in is
in [server.go ](https://github.com/binwiederhier/ntfy/blob/main/server/server.go ). Notably, the server uses a
[SQLite ](https://sqlite.org ) library called [go-sqlite3 ](https://github.com/mattn/go-sqlite3 ), which requires
[Cgo ](https://go.dev/blog/cgo ) and `CGO_ENABLED=1` to be set. Otherwise things will not work (see below).
* **The documentation** is generated by [MkDocs ](https://www.mkdocs.org/ ) and [Material for MkDocs ](https://squidfunk.github.io/mkdocs-material/ ),
which is written in [Python ](https://www.python.org/ ). You'll need Python and MkDocs (via `pip` ) only if you want to
build the docs.
* **The web app** is written in [React ](https://reactjs.org/ ), using [MUI ](https://mui.com/ ). If you want to modify the
web app, you need [nodejs ](https://nodejs.org/en/ ) (for `npm` ) to install all the 100,000 dependencies (*sigh*).
All of these components are built and then **baked into one binary** .
### Requirements
* [Go ](https://go.dev/ ) (required for main server)
* [gcc ](https://gcc.gnu.org/ ) (required main server, for SQLite cgo-based bindings)
* [Make ](https://www.gnu.org/software/make/ ) (required for convenience)
* [libsqlite3/libsqlite3-dev ](https://www.sqlite.org/ ) (required for main server, for SQLite cgo-based bindings)
* [GoReleaser ](https://goreleaser.com/ ) (required for a proper main server build)
* [Python ](https://www.python.org/ ) (for `pip` , only to build the docs)
* [nodejs ](https://nodejs.org/en/ ) (for `npm` , only to build the web app)
### Check out the code & install dependencies
Check out via git:
=== "via SSH"
```
git clone git@github.com:binwiederhier/ntfy.git
cd ntfy
```
=== "via HTTPS"
```
git clone https://github.com/binwiederhier/ntfy.git
cd ntfy
```
Then install the dependencies (this assumes Debian/Ubuntu):
```
sudo apt install build-essential libsqlite3-dev
```
To install Python/NodeJS (for docs and web app), please see instructions on their websites.
###
XXXXXXXXXXXXXXXXXXXXx
### Quick & dirty (amd64 only)
2021-12-02 23:27:31 +01:00
To quickly build on amd64, you can use `make build-simple` :
```
make build-simple
```
2022-03-17 03:33:23 +01:00
That'll generate a statically linked binary in `dist/ntfy_linux_amd64/ntfy` . This binary will **not include the docs
or the web app**. To include that
2021-12-02 23:27:31 +01:00
For all other platforms (including Docker), and for production or other snapshot builds, you should use the amazingly
awesome [GoReleaser ](https://goreleaser.com/ ) make targets:
```
Build:
make build - Build
make build-snapshot - Build snapshot
make build-simple - Build (using go build, without goreleaser)
make clean - Clean build folder
Releasing (requires goreleaser):
make release - Create a release
make release-snapshot - Create a test release
```
There are currently no platform-specific make targets, so they will build for all platforms (which may take a while).
2021-12-02 05:08:12 +01:00
## Android app
2021-12-04 02:38:21 +01:00
The ntfy Android app source code is available [on GitHub ](https://github.com/binwiederhier/ntfy-android ).
2021-12-02 23:27:31 +01:00
The Android app has two flavors:
* **Google Play:** The `play` flavor includes Firebase (FCM) and requires a Firebase account
* **F-Droid:** The `fdroid` flavor does not include Firebase or Google dependencies
First check out the repository:
```
2022-03-17 03:33:23 +01:00
git clone git@github.com:binwiederhier/ntfy-android.git # or: https://github.com/binwiederhier/ntfy-android.git
2021-12-02 23:27:31 +01:00
cd ntfy-android
```
Then either follow the steps for building with or without Firebase.
### Building without Firebase (F-Droid flavor)
Without Firebase, you may want to still change the default `app_base_url` in [strings.xml ](https://github.com/binwiederhier/ntfy-android/blob/main/app/src/main/res/values/strings.xml )
if you're self-hosting the server. Then run:
```
# To build an unsigned .apk (app/build/outputs/apk/fdroid/*.apk)
./gradlew assembleFdroidRelease
# To build a bundle .aab (app/fdroid/release/*.aab)
./gradlew bundleFdroidRelease
```
### Building with Firebase (FCM, Google Play flavor)
To build your own version with Firebase, you must:
* Create a Firebase/FCM account
* Place your account file at `app/google-services.json`
* And change `app_base_url` in [strings.xml ](https://github.com/binwiederhier/ntfy-android/blob/main/app/src/main/res/values/strings.xml )
* Then run:
```
# To build an unsigned .apk (app/build/outputs/apk/play/*.apk)
./gradlew assemblePlayRelease
# To build a bundle .aab (app/play/release/*.aab)
./gradlew bundlePlayRelease
```