diff --git a/Dockerfile b/Dockerfile index 44e3e8f..19ef720 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM debian:12 AS base WORKDIR /opt/app RUN apt-get update && \ + # apt-get install -y curl unzip cron ca-certificates python3 python3-pip && \ apt-get install -y curl unzip cron ca-certificates python3 python3-pip && \ rm -rf /var/lib/apt/lists/* # install BunJs @@ -19,8 +20,8 @@ COPY package.json bun.lock /temp/prod/ RUN cd /temp/prod && bun install --frozen-lockfile --production # and install python dependencies -COPY ./requirements.txt . -RUN python3 -m pip install --break-system-packages -r requirements.txt +# COPY ./requirements.txt . +# RUN python3 -m pip install --break-system-packages -r requirements.txt # RUN python3 -m pip install -U python-dotenv # copy node_modules from temp directory diff --git a/docker-compose.yml b/docker-compose.yml index 2570df8..2b45635 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,4 +2,21 @@ services: app: build: . volumes: - - ./data/db:/opt/app/data/db \ No newline at end of file + - ./data/db:/opt/app/data/db + apprise: + image: caronc/apprise:latest + environment: + - APPRISE_WORKER_COUNT=1 + - APPRISE_STATEFUL_MODE=simple + - PUID=$(id -u) + - PGID=$(id -g) + volumes: + - ./data/apprise/config:/config + - ./data/apprise/plugin:/plugin + - ./data/apprise/attach:/attach + ports: + - 8000:8000 +networks: + default: + external: true + name: npm \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index db8a048..384df25 100644 --- a/src/app.ts +++ b/src/app.ts @@ -112,11 +112,29 @@ async function main( ) { } return false; })( ev ); - await sendNotification( - `${today_prefix ? "TODAY " : ""}${notification_prefix ? notification_prefix + ": " : ""} ${ev.title} (${ TEventType[ ev.event_type ] })`, - `${body}` - // `${ev.link || "https://77th-jsoc.com/#/events"}` - ); + const title = `${today_prefix ? "TODAY " : ""}${notification_prefix ? notification_prefix + ": " : ""} ${ev.title} (${ TEventType[ ev.event_type ] })`; + + await fetch("http://localhost:8000/notify", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + urls: [ + `ntfys://${process.env.ntfy_username}:${process.env.ntfy_password}@${process.env.ntfy_host}/${process.env.ntfy_topic}${ ev.link ? `?click=${ev.link}`: "?click=https://77th-jsoc.com/#/events" }`, + `discord://${process.env.dc_webhook}?avatar_url=${process.env.dc_avatar_url}&botname=${process.env.dc_botname}` + ].join(","), + title: title, + body: body, + format: "text" + }) + }); + + // await sendNotification( + // title, + // body + // // `${ev.link || "https://77th-jsoc.com/#/events"}` + // ); ev.set_notification("done", db); } };