diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..3bf2a126
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+dist
+*/node_modules
+Dockerfile*
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index b7005328..23002306 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -5,3 +5,7 @@
c87549e71a10bc789eac8036078228f06e515a8e
ca5d736a7169eb6b4b0d849e061d5bf9565dcc53
2e27f58963feb9e4d1c573d4745d07770777fa7d
+
+# Run eslint (https://github.com/binwiederhier/ntfy/pull/748)
+f558b4dbe9bb5b9e0e87fada1215de2558353173
+8319f1cf26113167fb29fe12edaff5db74caf35f
diff --git a/Dockerfile-build b/Dockerfile-build
new file mode 100644
index 00000000..f8af256b
--- /dev/null
+++ b/Dockerfile-build
@@ -0,0 +1,53 @@
+FROM golang:1.19-bullseye as builder
+
+ARG VERSION=dev
+ARG COMMIT=unknown
+
+RUN apt-get update
+RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash
+RUN apt-get install -y \
+ build-essential \
+ nodejs \
+ python3-pip
+
+WORKDIR /app
+ADD Makefile .
+
+# docs
+ADD ./requirements.txt .
+RUN make docs-deps
+ADD ./mkdocs.yml .
+ADD ./docs ./docs
+RUN make docs-build
+
+# web
+ADD ./web/package.json ./web/package-lock.json ./web/
+RUN make web-deps
+ADD ./web ./web
+RUN make web-build
+
+# cli & server
+ADD go.mod go.sum main.go ./
+ADD ./client ./client
+ADD ./cmd ./cmd
+ADD ./log ./log
+ADD ./server ./server
+ADD ./user ./user
+ADD ./util ./util
+RUN make VERSION=$VERSION COMMIT=$COMMIT cli-linux-server
+
+FROM alpine
+
+LABEL org.opencontainers.image.authors="philipp.heckel@gmail.com"
+LABEL org.opencontainers.image.url="https://ntfy.sh/"
+LABEL org.opencontainers.image.documentation="https://docs.ntfy.sh/"
+LABEL org.opencontainers.image.source="https://github.com/binwiederhier/ntfy"
+LABEL org.opencontainers.image.vendor="Philipp C. Heckel"
+LABEL org.opencontainers.image.licenses="Apache-2.0, GPL-2.0"
+LABEL org.opencontainers.image.title="ntfy"
+LABEL org.opencontainers.image.description="Send push notifications to your phone or desktop using PUT/POST"
+
+COPY --from=builder /app/dist/ntfy_linux_server/ntfy /usr/bin/ntfy
+
+EXPOSE 80/tcp
+ENTRYPOINT ["ntfy"]
diff --git a/Makefile b/Makefile
index 6786acbe..8cb75238 100644
--- a/Makefile
+++ b/Makefile
@@ -31,12 +31,16 @@ help:
@echo " make cli-darwin-server - Build client & server (no GoReleaser, current arch, macOS)"
@echo " make cli-client - Build client only (no GoReleaser, current arch, Linux/macOS/Windows)"
@echo
+ @echo "Build dev Docker:"
+ @echo " make docker-dev - Build client & server for current architecture using Docker only"
+ @echo
@echo "Build web app:"
@echo " make web - Build the web app"
@echo " make web-deps - Install web app dependencies (npm install the universe)"
@echo " make web-build - Actually build the web app"
- @echo " make web-format - Run prettier on the web app
- @echo " make web-format-check - Run prettier on the web app, but don't change anything
+ @echo " make web-lint - Run eslint on the web app"
+ @echo " make web-format - Run prettier on the web app"
+ @echo " make web-format-check - Run prettier on the web app, but don't change anything"
@echo
@echo "Build documentation:"
@echo " make docs - Build the documentation"
@@ -82,16 +86,25 @@ build: web docs cli
update: web-deps-update cli-deps-update docs-deps-update
docker pull alpine
+docker-dev:
+ docker build \
+ --file ./Dockerfile-build \
+ --tag binwiederhier/ntfy:$(VERSION) \
+ --tag binwiederhier/ntfy:dev \
+ --build-arg VERSION=$(VERSION) \
+ --build-arg COMMIT=$(COMMIT) \
+ ./
+
# Ubuntu-specific
build-deps-ubuntu:
- sudo apt update
- sudo apt install -y \
+ sudo apt-get update
+ sudo apt-get install -y \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi \
jq
- which pip3 || sudo apt install -y python3-pip
+ which pip3 || sudo apt-get install -y python3-pip
# Documentation
@@ -129,8 +142,7 @@ web-build:
&& rm -rf ../server/site \
&& mv build ../server/site \
&& rm \
- ../server/site/config.js \
- ../server/site/asset-manifest.json
+ ../server/site/config.js
web-deps:
cd web && npm install
@@ -145,6 +157,9 @@ web-format:
web-format-check:
cd web && npm run format:check
+web-lint:
+ cd web && npm run lint
+
# Main server/client build
cli: cli-deps
@@ -233,7 +248,7 @@ cli-build-results:
# Test/check targets
-check: test web-format-check fmt-check vet lint staticcheck
+check: test web-format-check fmt-check vet web-lint lint staticcheck
test: .PHONY
go test $(shell go list ./... | grep -vE 'ntfy/(test|examples|tools)')
diff --git a/docs/develop.md b/docs/develop.md
index a53c5033..baab3f3a 100644
--- a/docs/develop.md
+++ b/docs/develop.md
@@ -163,6 +163,15 @@ $ make release-snapshot
During development, you may want to be more picky and build only certain things. Here are a few examples.
+### Build a Docker image only for Linux
+
+This is useful to test the final build with web app, docs, and server without any dependencies locally
+
+``` shell
+$ make docker-dev
+$ docker run --rm -p 80:80 binwiederhier/ntfy:dev serve
+```
+
### Build the ntfy binary
To build only the `ntfy` binary **without the web app or documentation**, use the `make cli-...` targets:
diff --git a/docs/releases.md b/docs/releases.md
index 523f46f6..71fceb1e 100644
--- a/docs/releases.md
+++ b/docs/releases.md
@@ -1222,8 +1222,13 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
### ntfy server v2.6.0 (UNRELEASED)
-**Bug fixes + maintenance:**
+**Bug fixes:**
* Support encoding any header as RFC 2047 ([#737](https://github.com/binwiederhier/ntfy/issues/737), thanks to [@cfouche3005](https://github.com/cfouche3005) for reporting)
+
+**Maintenance:**
+
* Improved GitHub Actions flow ([#745](https://github.com/binwiederhier/ntfy/pull/745), thanks to [@nimbleghost](https://github.com/nimbleghost))
* Web: Add JS formatter "prettier" ([#746](https://github.com/binwiederhier/ntfy/pull/746), thanks to [@nimbleghost](https://github.com/nimbleghost))
+* Web: Add eslint with eslint-config-airbnb ([#748](https://github.com/binwiederhier/ntfy/pull/748), thanks to [@nimbleghost](https://github.com/nimbleghost))
+* Web: Switch to Vite ([#749](https://github.com/binwiederhier/ntfy/pull/749), thanks to [@nimbleghost](https://github.com/nimbleghost))
diff --git a/server/server_test.go b/server/server_test.go
index fe84b856..73df2762 100644
--- a/server/server_test.go
+++ b/server/server_test.go
@@ -219,7 +219,7 @@ func TestServer_StaticSites(t *testing.T) {
rr = request(t, s, "GET", "/mytopic", "", nil)
require.Equal(t, 200, rr.Code)
- require.Contains(t, rr.Body.String(), ``)
+ require.Contains(t, rr.Body.String(), ``)
rr = request(t, s, "GET", "/docs", "", nil)
require.Equal(t, 301, rr.Code)
diff --git a/web/.eslintignore b/web/.eslintignore
new file mode 100644
index 00000000..29c9584b
--- /dev/null
+++ b/web/.eslintignore
@@ -0,0 +1 @@
+src/app/emojis.js
\ No newline at end of file
diff --git a/web/.eslintrc b/web/.eslintrc
new file mode 100644
index 00000000..adf66130
--- /dev/null
+++ b/web/.eslintrc
@@ -0,0 +1,37 @@
+{
+ "extends": ["airbnb", "prettier"],
+ "env": {
+ "browser": true
+ },
+ "globals": {
+ "config": "readonly"
+ },
+ "parserOptions": {
+ "ecmaVersion": 2023
+ },
+ "rules": {
+ "no-console": "off",
+ "class-methods-use-this": "off",
+ "func-style": ["error", "expression"],
+ "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
+ "no-await-in-loop": "error",
+ "import/no-cycle": "warn",
+ "react/prop-types": "off",
+ "react/destructuring-assignment": "off",
+ "react/jsx-no-useless-fragment": "off",
+ "react/jsx-props-no-spreading": "off",
+ "react/jsx-no-duplicate-props": [
+ "error",
+ {
+ "ignoreCase": false // For 's [iI]nputProps
+ }
+ ],
+ "react/function-component-definition": [
+ "error",
+ {
+ "namedComponents": "arrow-function",
+ "unnamedComponents": "arrow-function"
+ }
+ ]
+ }
+}
diff --git a/web/.prettierignore b/web/.prettierignore
index 14652726..802cdb8d 100644
--- a/web/.prettierignore
+++ b/web/.prettierignore
@@ -1,3 +1,4 @@
build/
dist/
public/static/langs/
+src/app/emojis.js
diff --git a/web/public/index.html b/web/index.html
similarity index 80%
rename from web/public/index.html
rename to web/index.html
index e8c7f8a6..c146e64d 100644
--- a/web/public/index.html
+++ b/web/index.html
@@ -15,7 +15,7 @@
-
+
@@ -26,15 +26,15 @@
property="og:description"
content="ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy."
/>
-
+
-
-
+
+
-
+
+