diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 000000000..4a34b2115 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,28 @@ +# Codespaces + +You can modifiy Uptime Kuma in your browser without setting up a local development. + +![image](https://github.com/louislam/uptime-kuma/assets/1336778/31d9f06d-dd0b-4405-8e0d-a96586ee4595) + +1. Click `Code` -> `Create codespace on master` +2. Wait a few minutes until you see there are two exposed ports +3. Go to the `3000` url, see if it is working + +![image](https://github.com/louislam/uptime-kuma/assets/1336778/909b2eb4-4c5e-44e4-ac26-6d20ed856e7f) + +## Frontend + +Since the frontend is using [Vite.js](https://vitejs.dev/), all changes in this area will be hot-reloaded. +You don't need to restart the frontend, unless you try to add a new frontend dependency. + +## Backend + +The backend does not automatically hot-reload. +You will need to restart the backend after changing something using these steps: + +1. Click `Terminal` +2. Click `Codespaces: server-dev` in the right panel +3. Press `Ctrl + C` to stop the server +4. Press `Up` to run `npm run start-server-dev` + +![image](https://github.com/louislam/uptime-kuma/assets/1336778/e0c0a350-fe46-4588-9f37-e053c85834d1) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..5b3ceabc8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +{ + "image": "mcr.microsoft.com/devcontainers/javascript-node:dev-18-bookworm", + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "updateContentCommand": "npm ci", + "postCreateCommand": "", + "postAttachCommand": { + "frontend-dev": "npm run start-frontend-devcontainer", + "server-dev": "npm run start-server-dev", + "open-port": "gh codespace ports visibility 3001:public -c $CODESPACE_NAME" + }, + "customizations": { + "vscode": { + "extensions": [ + "streetsidesoftware.code-spell-checker", + "dbaeumer.vscode-eslint" + ] + } + }, + "forwardPorts": [3000, 3001] +} diff --git a/.github/ISSUE_TEMPLATE/ask-for-help.yaml b/.github/ISSUE_TEMPLATE/ask-for-help.yaml index 9c30b2dc8..c082b2e34 100644 --- a/.github/ISSUE_TEMPLATE/ask-for-help.yaml +++ b/.github/ISSUE_TEMPLATE/ask-for-help.yaml @@ -44,7 +44,7 @@ body: id: operating-system attributes: label: "💻 Operating System and Arch" - description: "Which OS is your server/device running on?" + description: "Which OS is your server/device running on? (For Replit, please do not report this bug)" placeholder: "Ex. Ubuntu 20.04 x86" validations: required: true @@ -52,7 +52,7 @@ body: id: browser-vendor attributes: label: "🌐 Browser" - description: "Which browser are you running on?" + description: "Which browser are you running on? (For Replit, please do not report this bug)" placeholder: "Ex. Google Chrome 95.0.4638.69" validations: required: true diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 023b7aa1b..e1e43ccfb 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -1,4 +1,4 @@ -# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: Auto Test @@ -33,7 +33,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - cache: 'npm' - run: npm install npm@latest -g - run: npm install - run: npm run build @@ -51,7 +50,7 @@ jobs: strategy: matrix: os: [ ARMv7 ] - node: [ 14, 18 ] + node: [ 14.21.3, 18.16.1 ] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -62,7 +61,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - cache: 'npm' - run: npm install npm@latest -g - run: npm ci --production @@ -77,7 +75,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 14 - cache: 'npm' - run: npm install - run: npm run lint @@ -92,7 +89,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 14 - cache: 'npm' - run: npm install - run: npm run build - run: npm run cy:test @@ -108,7 +104,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 14 - cache: 'npm' - run: npm install - run: npm run build - run: npm run cy:run:unit diff --git a/README.md b/README.md index 3f8a05403..0e41652df 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ It is a temporary live demo, all data will be deleted after 10 minutes. Use the ## ⭐ Features -* Monitoring uptime for HTTP(s) / TCP / HTTP(s) Keyword / Ping / DNS Record / Push / Steam Game Server / Docker Containers +* Monitoring uptime for HTTP(s) / TCP / HTTP(s) Keyword / HTTP(s) Json Query / Ping / DNS Record / Push / Steam Game Server / Docker Containers * Fancy, Reactive, Fast UI/UX * Notifications via Telegram, Discord, Gotify, Slack, Pushover, Email (SMTP), and [90+ notification services, click here for the full list](https://github.com/louislam/uptime-kuma/tree/master/src/components/notifications) * 20 second intervals @@ -49,14 +49,14 @@ Uptime Kuma is now running on http://localhost:3001 ### 💪🏻 Non-Docker -Requirements: +Requirements: - Platform - - ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc. + - ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc. - ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher - ❌ Replit / Heroku -- [Node.js](https://nodejs.org/en/download/) 14 / 16 / 18 (20 is not supported) +- [Node.js](https://nodejs.org/en/download/) 14 / 16 / 18 / 20.4 - [npm](https://docs.npmjs.com/cli/) >= 7 -- [Git](https://git-scm.com/downloads) +- [Git](https://git-scm.com/downloads) - [pm2](https://pm2.keymetrics.io/) - For running Uptime Kuma in the background ```bash @@ -71,7 +71,7 @@ npm run setup node server/server.js # (Recommended) Option 2. Run in background using PM2 -# Install PM2 if you don't have it: +# Install PM2 if you don't have it: npm install pm2 -g && pm2 install pm2-logrotate # Start Server diff --git a/config/vite.config.js b/config/vite.config.js index 6e9ebbde8..11c610066 100644 --- a/config/vite.config.js +++ b/config/vite.config.js @@ -3,6 +3,7 @@ import vue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; import visualizer from "rollup-plugin-visualizer"; import viteCompression from "vite-plugin-compression"; +import commonjs from "vite-plugin-commonjs"; const postCssScss = require("postcss-scss"); const postcssRTLCSS = require("postcss-rtlcss"); @@ -16,8 +17,12 @@ export default defineConfig({ }, define: { "FRONTEND_VERSION": JSON.stringify(process.env.npm_package_version), + "DEVCONTAINER": JSON.stringify(process.env.DEVCONTAINER), + "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN": JSON.stringify(process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN), + "CODESPACE_NAME": JSON.stringify(process.env.CODESPACE_NAME), }, plugins: [ + commonjs(), vue(), legacy({ targets: [ "since 2015" ], @@ -42,6 +47,9 @@ export default defineConfig({ } }, build: { + commonjsOptions: { + include: [ /.js$/ ], + }, rollupOptions: { output: { manualChunks(id, { getModuleInfo, getModuleIds }) { diff --git a/db/patch-add-invert-keyword.sql b/db/patch-add-invert-keyword.sql new file mode 100644 index 000000000..8ca199eed --- /dev/null +++ b/db/patch-add-invert-keyword.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD invert_keyword BOOLEAN default 0 not null; + +COMMIT; diff --git a/db/patch-added-json-query.sql b/db/patch-added-json-query.sql new file mode 100644 index 000000000..d5b7f1a8f --- /dev/null +++ b/db/patch-added-json-query.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD json_path TEXT; + +ALTER TABLE monitor + ADD expected_value VARCHAR(255); + +COMMIT; diff --git a/db/patch-added-kafka-producer.sql b/db/patch-added-kafka-producer.sql new file mode 100644 index 000000000..933d30b8f --- /dev/null +++ b/db/patch-added-kafka-producer.sql @@ -0,0 +1,22 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD kafka_producer_topic VARCHAR(255); + +ALTER TABLE monitor + ADD kafka_producer_brokers TEXT; + +ALTER TABLE monitor + ADD kafka_producer_ssl INTEGER; + +ALTER TABLE monitor + ADD kafka_producer_allow_auto_topic_creation VARCHAR(255); + +ALTER TABLE monitor + ADD kafka_producer_sasl_options TEXT; + +ALTER TABLE monitor + ADD kafka_producer_message TEXT; + +COMMIT; diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile index f84aa32a6..a78c7329c 100644 --- a/docker/debian-base.dockerfile +++ b/docker/debian-base.dockerfile @@ -2,13 +2,35 @@ FROM node:18-bullseye-slim AS base2-slim ARG TARGETPLATFORM -RUN apt update && \ - apt --yes --no-install-recommends install python3 python3-pip python3-cryptography python3-six python3-yaml python3-click python3-markdown python3-requests python3-requests-oauthlib \ - sqlite3 iputils-ping util-linux dumb-init git curl ca-certificates && \ - pip3 --no-cache-dir install apprise==1.4.0 && \ +WORKDIR /app + +# Specify --no-install-recommends to skip unused dependencies, make the base much smaller! +# python3* = apprise's dependencies +# sqlite3 = for debugging +# iputils-ping = for ping +# util-linux = for setpriv (Should be dropped in 2.0.0?) +# dumb-init = avoid zombie processes (#480) +# curl = for debugging +# ca-certificates = keep the cert up-to-date +# sudo = for start service nscd with non-root user +# nscd = for better DNS caching +# (pip) apprise = for notifications +RUN apt-get update && \ + apt-get --yes --no-install-recommends install \ + python3 python3-pip python3-cryptography python3-six python3-yaml python3-click python3-markdown python3-requests python3-requests-oauthlib \ + sqlite3 \ + iputils-ping \ + util-linux \ + dumb-init \ + curl \ + ca-certificates \ + sudo \ + nscd && \ + pip3 --no-cache-dir install apprise==1.4.5 && \ rm -rf /var/lib/apt/lists/* && \ apt --yes autoremove + # Install cloudflared RUN curl https://pkg.cloudflare.com/cloudflare-main.gpg --output /usr/share/keyrings/cloudflare-main.gpg && \ echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared bullseye main' | tee /etc/apt/sources.list.d/cloudflared.list && \ @@ -18,6 +40,11 @@ RUN curl https://pkg.cloudflare.com/cloudflare-main.gpg --output /usr/share/keyr rm -rf /var/lib/apt/lists/* && \ apt --yes autoremove +# For nscd +COPY ./docker/etc/nscd.conf /etc/nscd.conf +COPY ./docker/etc/sudoers /etc/sudoers + + # Full Base Image # MariaDB, Chromium and fonts # Not working for armv7, so use the older version (10.5) of MariaDB from the debian repo @@ -30,5 +57,3 @@ RUN apt update && \ rm -rf /var/lib/apt/lists/* && \ apt --yes autoremove && \ chown -R node:node /var/lib/mysql - - diff --git a/docker/etc/nscd.conf b/docker/etc/nscd.conf new file mode 100644 index 000000000..18b92bfee --- /dev/null +++ b/docker/etc/nscd.conf @@ -0,0 +1,90 @@ +# +# /etc/nscd.conf +# +# An example Name Service Cache config file. This file is needed by nscd. +# +# Legal entries are: +# +# logfile +# debug-level +# threads +# max-threads +# server-user +# server-user is ignored if nscd is started with -S parameters +# stat-user +# reload-count unlimited| +# paranoia +# restart-interval