3 Commits

Author SHA1 Message Date
b2b72b3b88 Merge branch 'main' of https://git.n8x.sx/chiko/77th_eventcalenderntfy 2025-10-21 23:49:40 +02:00
2bcd3a4d61 merging... 2025-10-21 23:47:11 +02:00
999bdf7222 fix-docker (#1)
Reviewed-on: #1
2025-10-21 00:52:32 +00:00
5 changed files with 89 additions and 1 deletions

2
Crontab Normal file
View File

@@ -0,0 +1,2 @@
1 * * * * bun run ./src/app.ts --today > /dev/null 2>&1
0 * * * * bun run ./src/app.ts > /dev/null 2>&1

View File

@@ -4,6 +4,7 @@ ARG VERSION
LABEL build_version="77th_eventcalendarntfy ${VERSION}, Build-date:- ${BUILD_DATE}" LABEL build_version="77th_eventcalendarntfy ${VERSION}, Build-date:- ${BUILD_DATE}"
LABEL maintainer="chiko <chiko@xcsone.de>" LABEL maintainer="chiko <chiko@xcsone.de>"
WORKDIR /opt/app WORKDIR /opt/app
<<<<<<< HEAD
RUN set -eux && \ RUN set -eux && \
echo "Updating APT" && \ echo "Updating APT" && \
apt-get update -y -qq && \ apt-get update -y -qq && \
@@ -19,6 +20,12 @@ RUN set -eux && \
rm --recursive --force --verbose /var/tmp/* && \ rm --recursive --force --verbose /var/tmp/* && \
rm --recursive --force --verbose /var/cache/apt/archives/* && \ rm --recursive --force --verbose /var/cache/apt/archives/* && \
truncate --size 0 /var/log/*log truncate --size 0 /var/log/*log
=======
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/*
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
# install BunJs # install BunJs
RUN curl -fsSL https://bun.com/install | bash RUN curl -fsSL https://bun.com/install | bash
ENV PATH="/root/.bun/bin:$PATH" ENV PATH="/root/.bun/bin:$PATH"
@@ -34,26 +41,49 @@ RUN mkdir -p /temp/prod
COPY package.json bun.lock /temp/prod/ COPY package.json bun.lock /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production RUN cd /temp/prod && bun install --frozen-lockfile --production
<<<<<<< HEAD
COPY ./docker/Crontab /etc/cron.d/ COPY ./docker/Crontab /etc/cron.d/
RUN chmod 0644 /etc/cron.d/Crontab RUN chmod 0644 /etc/cron.d/Crontab
COPY ./docker/cron-bun-log /etc/logrotate.d/ COPY ./docker/cron-bun-log /etc/logrotate.d/
RUN mkdir /var/log/cron && touch /var/log/cron.log RUN mkdir /var/log/cron && touch /var/log/cron.log
=======
# and install python dependencies
# COPY ./requirements.txt .
# RUN python3 -m pip install --break-system-packages -r requirements.txt
# RUN python3 -m pip install -U python-dotenv
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
# copy node_modules from temp directory # copy node_modules from temp directory
# then copy all (non-ignored) project files into the image # then copy all (non-ignored) project files into the image
FROM base AS prerelease FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules COPY --from=install /temp/dev/node_modules node_modules
COPY . ./ COPY . ./
<<<<<<< HEAD
=======
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
# [optional] tests & build # [optional] tests & build
ENV NODE_ENV=production ENV NODE_ENV=production
# copy production dependencies and source code into final image # copy production dependencies and source code into final image
FROM base AS release FROM base AS release
WORKDIR /opt/app
COPY --from=install /temp/prod/node_modules node_modules COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /opt/app/package.json . COPY --from=prerelease /opt/app/package.json .
#COPY --from=prerelease .entrypoint.sh . #COPY --from=prerelease .entrypoint.sh .
<<<<<<< HEAD
COPY . ./ COPY . ./
RUN mkdir /var/log/cron && touch /var/log/cron.log RUN mkdir /var/log/cron && touch /var/log/cron.log
VOLUME /opt/app/data/db VOLUME /opt/app/data/db
# VOLUME /var/log/cron # VOLUME /var/log/cron
=======
COPY Crontab /etc/cron.d/
RUN chmod 0644 /etc/cron.d/Crontab
COPY . ./
# USER bun
RUN touch /var/log/cron.log
# RUN chmod +x entrypoint.sh
# ENTRYPOINT ["./entrypoint.sh"]
VOLUME /opt/app/data/db
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
CMD bun run ./src/app.ts --today && cron && tail -f /var/log/cron.log CMD bun run ./src/app.ts --today && cron && tail -f /var/log/cron.log

View File

@@ -3,7 +3,10 @@ services:
build: . build: .
volumes: volumes:
- ./data/db:/opt/app/data/db - ./data/db:/opt/app/data/db
<<<<<<< HEAD
- ./data/app/log:/var/log - ./data/app/log:/var/log
=======
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
env_file: env_file:
- path: ./.env - path: ./.env
required: true required: true
@@ -24,12 +27,21 @@ services:
- ./data/apprise/config:/config - ./data/apprise/config:/config
- ./data/apprise/plugin:/plugin - ./data/apprise/plugin:/plugin
- ./data/apprise/attach:/attach - ./data/apprise/attach:/attach
<<<<<<< HEAD
# ports: # ports:
#- 8880:8000 #- 8880:8000
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/status"] test: ["CMD", "curl", "-f", "http://localhost:8000/status"]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
=======
ports:
- 8000:8000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/status"]
interval: 30s
timeout: 10s
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
retries: 5 retries: 5
# networks: # networks:
# default: # default:

View File

@@ -116,8 +116,33 @@ async function main ( ) {
return false; return false;
})( ev ); })( ev );
const title = `${today_prefix ? "TODAY " : ""}${notification_prefix ? notification_prefix + ": " : ""} ${ev.title} (${ TEventType[ ev.event_type ] })`; const title = `${today_prefix ? "TODAY " : ""}${notification_prefix ? notification_prefix + ": " : ""} ${ev.title} (${ TEventType[ ev.event_type ] })`;
<<<<<<< HEAD
console.log("loop list_of_events - ev 'title': " + title ); console.log("loop list_of_events - ev 'title': " + title );
await sendNotification( title, body, ev.link ? ev.link : null); await sendNotification( title, body, ev.link ? ev.link : null);
=======
await fetch("http://apprise: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"}`
// );
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a
ev.set_notification("done", db); ev.set_notification("done", db);
} }
}; };

View File

@@ -1,3 +1,4 @@
<<<<<<< HEAD
export async function sendNotification(title: string, body: string, link?: string | null) { export async function sendNotification(title: string, body: string, link?: string | null) {
console.dir({ console.dir({
sendNotification: { sendNotification: {
@@ -23,4 +24,22 @@ export async function sendNotification(title: string, body: string, link?: strin
}); });
const responseBody = await response.json(); const responseBody = await response.json();
return responseBody; return responseBody;
} }
=======
import * as Bun from "bun";
export async function sendNotification(title: string, body: string, click?: string | null) {
const command = [
"python3",
"./src/notification.py",
`--title=${title}`,
`--body=${body}`,
];
if ( click ) {
command.push(`--click=${click}`);
}
const proc = Bun.spawn(command);
const text = await proc.stdout.text();
console.log("sendNotification: " + text);
}
>>>>>>> 999bdf7222a68995dd40ec7da967b360f67d354a