Merge remote-tracking branch 'upstream/main' into main

This commit is contained in:
KillahBee 2023-01-23 15:26:47 -05:00
commit cf19158bda
45 changed files with 164 additions and 144 deletions

View File

@ -7,12 +7,10 @@ WORKDIR /app
COPY --link package.json pnpm-lock.yaml* ./
RUN <<EOF
set -xe
apk add libc6-compat
apk add --virtual .gyp python3 make g++
npm install -g pnpm
EOF
SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
RUN apk add --no-cache libc6-compat \
&& apk add --no-cache --virtual .gyp python3 make g++ \
&& npm install -g pnpm
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm fetch | grep -v "cross-device link not permitted\|Falling back to copying packages from store"
@ -29,12 +27,10 @@ ARG REVISION
COPY --link --from=deps /app/node_modules ./node_modules/
COPY . .
RUN <<EOF
set -xe
npm run telemetry
mkdir config && echo '-' > config/settings.yaml
NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
EOF
SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
RUN npm run telemetry \
&& mkdir config && echo '---' > config/settings.yaml \
&& NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
# Production image, copy all the files and run next
FROM docker.io/node:18-alpine AS runner
@ -50,12 +46,15 @@ ENV NODE_ENV production
WORKDIR /app
# Copy files from context (this allows the files to copy before the builder stage is done).
COPY --link package.json next.config.js ./
COPY --link /public ./public
COPY --link --chown=1000:1000 package.json next.config.js ./
COPY --link --chown=1000:1000 /public ./public/
# Copy files from builder
COPY --link --from=builder /app/.next/standalone ./
COPY --link --from=builder /app/.next/static/ ./.next/static/
COPY --link --from=builder --chown=1000:1000 /app/.next/standalone ./
COPY --link --from=builder --chown=1000:1000 /app/.next/static/ ./.next/static/
COPY --link --chmod=755 docker-entrypoint.sh /usr/local/bin/
RUN apk add --no-cache su-exec
ENV PORT 3000
EXPOSE $PORT
@ -63,4 +62,5 @@ EXPOSE $PORT
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \
CMD wget --no-verbose --tries=1 --spider --no-check-certificate http://localhost:$PORT/api/healthcheck || exit 1
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]

View File

@ -2,8 +2,22 @@
set -e
# Default to root, so old installations won't break
export PUID=${PUID:-0}
export PGID=${PGID:-0}
# This is in attempt to preserve the original behavior of the Dockerfile,
# while also supporting the lscr.io /config directory
[ ! -d "/app/config" ] && ln -s /config /app/config
node server.js
# Set privileges for /app but only if pid 1 user is root and we are dropping privileges.
# If container is run as an unprivileged user, it means owner already handled ownership setup on their own.
# Running chown in that case (as non-root) will cause error
[ "$(id -u)" == "0" ] && [ "${PUID}" != "0" ] && chown -R ${PUID}:${PGID} /app
# Drop privileges (when asked to) if root, otherwise run as current user
if [ "$(id -u)" == "0" ] && [ "${PUID}" != "0" ]; then
su-exec ${PUID}:${PGID} "$@"
else
exec "$@"
fi

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -424,7 +424,7 @@
"print_progress": "Progress",
"layers": "Layers"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,10 +415,10 @@
"queued": "A la espera",
"series": "Serie"
},
"octoPrint": {
"octoprint": {
"temp_bed": "Bed temp",
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",
"job_completion": "Completion"
}
}

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "En attente",
"series": "Séries"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,10 +415,10 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"temp_bed": "Bed temp",
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",
"job_completion": "Completion"
}
}

View File

@ -415,7 +415,7 @@
"print_progress": "Progress",
"layers": "Layers"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -394,28 +394,28 @@
"numberOfLeases": "Dzierżawy"
},
"xteve": {
"streams_all": "All Streams",
"streams_active": "Active Streams",
"streams_xepg": "XEPG Channels"
"streams_all": "Wszystkie strumienie",
"streams_active": "Aktywne strumienie",
"streams_xepg": "Kanały XEPG"
},
"opnsense": {
"cpu": "CPU Load",
"memory": "Active Memory",
"wanUpload": "WAN Upload",
"wanDownload": "WAN Download"
"cpu": "Obciążenie procesora",
"memory": "Pamięć rzeczywista",
"wanUpload": "WAN wysyłanie",
"wanDownload": "WAN pobieranie"
},
"moonraker": {
"printer_state": "Printer State",
"print_status": "Print Status",
"print_progress": "Progress",
"layers": "Layers"
"printer_state": "Stan drukarki",
"print_status": "Status wydruku",
"print_progress": "Postęp",
"layers": "Warstwy"
},
"medusa": {
"wanted": "Wanted",
"queued": "Queued",
"series": "Series"
"wanted": "Poszukiwane",
"queued": "Zakolejkowane",
"series": "Seria"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -424,7 +424,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "У черзі",
"series": "Серії"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -415,7 +415,7 @@
"queued": "Queued",
"series": "Series"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -61,20 +61,20 @@
"timeleft": "剩餘時間"
},
"rutorrent": {
"active": "Active",
"upload": "上",
"download": "下"
"active": "活動中",
"upload": "上行速率",
"download": "下行速率"
},
"radarr": {
"movies": "電影",
"wanted": "關注中",
"queued": "已加入佇列",
"missing": "遺失"
"missing": "缺少"
},
"sonarr": {
"wanted": "關注中",
"queued": "已加入佇列",
"series": "系列"
"series": "影集"
},
"readarr": {
"wanted": "關注中",
@ -93,13 +93,13 @@
"processing": "處理中"
},
"pihole": {
"queries": "查詢",
"queries": "查詢",
"blocked": "已阻擋",
"gravity": "Gravity"
},
"speedtest": {
"upload": "上行",
"download": "下行",
"upload": "上行速率",
"download": "下行速率",
"ping": "Ping"
},
"portainer": {
@ -132,23 +132,23 @@
"prowlarr": {
"enableIndexers": "索引器",
"numberOfGrabs": "抓取",
"numberOfQueries": "查詢",
"numberOfQueries": "查詢",
"numberOfFailGrabs": "抓取失敗",
"numberOfFailQueries": "查詢失敗"
},
"transmission": {
"download": "下",
"upload": "上",
"leech": "Leech",
"seed": "Seed"
"download": "下行速率",
"upload": "上行速率",
"leech": "未完成下載",
"seed": "已完成下載"
},
"jackett": {
"configured": "已配置",
"errored": "發生錯誤"
},
"bazarr": {
"missingEpisodes": "缺的劇集",
"missingMovies": "缺的電影"
"missingEpisodes": "缺的劇集",
"missingMovies": "缺的電影"
},
"lidarr": {
"wanted": "關注中",
@ -156,16 +156,16 @@
"albums": "專輯"
},
"adguard": {
"queries": "查詢",
"queries": "查詢",
"blocked": "已阻擋",
"filtered": "已過濾",
"latency": "延遲"
},
"qbittorrent": {
"download": "下",
"upload": "上",
"leech": "Leech",
"seed": "Seed"
"download": "下行速率",
"upload": "上行速率",
"leech": "未完成下載",
"seed": "已完成下載"
},
"mastodon": {
"user_count": "使用者",
@ -216,8 +216,8 @@
"wait": "請稍後"
},
"changedetectionio": {
"totalObserved": "Total Observed",
"diffsDetected": "Diffs Detected"
"totalObserved": "總監測數",
"diffsDetected": "偵測到的變更"
},
"wmo": {
"0-day": "晴",
@ -345,16 +345,16 @@
"total": "全部"
},
"deluge": {
"download": "下",
"upload": "上",
"leech": "Leech",
"seed": "Seed"
"download": "下行速率",
"upload": "上行速率",
"leech": "未完成下載",
"seed": "已完成下載"
},
"flood": {
"download": "下",
"upload": "上",
"leech": "Leech",
"seed": "Seed"
"download": "下行速率",
"upload": "上行速率",
"leech": "未完成下載",
"seed": "已完成下載"
},
"tdarr": {
"queue": "佇列",
@ -382,10 +382,10 @@
"connectedSwitches": "已連接的交換器"
},
"downloadstation": {
"download": "下",
"upload": "上",
"leech": "Leech",
"seed": "Seed"
"download": "下行速率",
"upload": "上行速率",
"leech": "未完成下載",
"seed": "已完成下載"
},
"mikrotik": {
"cpuLoad": "CPU負載",
@ -405,17 +405,17 @@
"wanDownload": "WAN下載"
},
"moonraker": {
"printer_state": "Printer State",
"print_status": "Print Status",
"print_progress": "Progress",
"layers": "Layers"
"printer_state": "列印機狀態",
"print_status": "列印狀態",
"print_progress": "進度",
"layers": ""
},
"medusa": {
"wanted": "Wanted",
"queued": "Queued",
"series": "Series"
"wanted": "關注中",
"queued": "已加入佇列",
"series": "影集"
},
"octoPrint": {
"octoprint": {
"printer_state": "Status",
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",

View File

@ -1,16 +1,18 @@
import Docker from "dockerode";
import getDockerArguments from "utils/config/docker";
import createLogger from "utils/logger";
const logger = createLogger("dockerStatsService");
export default async function handler(req, res) {
const { service } = req.query;
const [containerName, containerServer] = service;
if (!containerName && !containerServer) {
res.status(400).send({
return res.status(400).send({
error: "docker query parameters are required",
});
return;
}
try {
@ -23,10 +25,9 @@ export default async function handler(req, res) {
// bad docker connections can result in a <Buffer ...> object?
// in any case, this ensures the result is the expected array
if (!Array.isArray(containers)) {
res.status(500).send({
return res.status(500).send({
error: "query failed",
});
return;
}
const containerNames = containers.map((container) => container.Names[0].replace(/^\//, ""));
@ -36,10 +37,9 @@ export default async function handler(req, res) {
const container = docker.getContainer(containerName);
const stats = await container.stats({ stream: false });
res.status(200).json({
return res.status(200).json({
stats,
});
return;
}
// Try with a service deployed in Docker Swarm, if enabled
@ -61,19 +61,19 @@ export default async function handler(req, res) {
const container = docker.getContainer(taskContainerId);
const stats = await container.stats({ stream: false });
res.status(200).json({
return res.status(200).json({
stats,
});
return;
}
}
res.status(200).send({
return res.status(200).send({
error: "not found",
});
} catch {
res.status(500).send({
error: {message: "Unknown error"},
} catch (e) {
logger.error(e);
return res.status(500).send({
error: {message: e?.message ?? "Unknown error"},
});
}
}

View File

@ -1,6 +1,9 @@
import Docker from "dockerode";
import getDockerArguments from "utils/config/docker";
import createLogger from "utils/logger";
const logger = createLogger("dockerStatusService");
export default async function handler(req, res) {
const { service } = req.query;
@ -68,9 +71,10 @@ export default async function handler(req, res) {
return res.status(200).send({
error: "not found",
});
} catch {
} catch (e) {
logger.error(e);
return res.status(500).send({
error: "unknown error",
error: {message: e?.message ?? "Unknown error"},
});
}
}

View File

@ -214,7 +214,8 @@ export function cleanServiceGroups(groups) {
defaultinterval,
namespace, // kubernetes widget
app,
podSelector
podSelector,
wan // opnsense widget
} = cleanedService.widget;
cleanedService.widget = {
@ -237,6 +238,9 @@ export function cleanServiceGroups(groups) {
if (app) cleanedService.widget.app = app;
if (podSelector) cleanedService.widget.podSelector = podSelector;
}
if (type === "opnsense") {
if (wan) cleanedService.widget.wan = wan;
}
}
return cleanedService;

View File

@ -31,7 +31,7 @@ const components = {
nextdns: dynamic(() => import("./nextdns/component")),
npm: dynamic(() => import("./npm/component")),
nzbget: dynamic(() => import("./nzbget/component")),
octoPrint: dynamic(() => import("./octoPrint/component")),
octoprint: dynamic(() => import("./octoprint/component")),
omada: dynamic(() => import("./omada/component")),
ombi: dynamic(() => import("./ombi/component")),
opnsense: dynamic(() => import("./opnsense/component")),

View File

@ -23,7 +23,7 @@ export default function Component({ service }) {
if (!printerStats || !state || !tempTool || !tempBed) {
return (
<Container service={service}>
<Block label="octoPrint.printer_state" />
<Block label="octoprint.printer_state" />
</Container>
);
}
@ -36,29 +36,29 @@ export default function Component({ service }) {
if (!jobStats || !completion) {
return (
<Container service={service}>
<Block label="octoPrint.printer_state" />
<Block label="octoPrint.temp_tool" />
<Block label="octoPrint.temp_bed" />
<Block label="octoPrint.job_completion" />
<Block label="octoprint.printer_state" />
<Block label="octoprint.temp_tool" />
<Block label="octoprint.temp_bed" />
<Block label="octoprint.job_completion" />
</Container>
);
}
return (
<Container service={service}>
<Block label="octoPrint.printer_state" value={printerStats.state.text} />
<Block label="octoPrint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} />
<Block label="octoPrint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} />
<Block label="octoPrint.job_completion" value={`${completion.toFixed(2)}%`} />
<Block label="octoprint.printer_state" value={printerStats.state.text} />
<Block label="octoprint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} />
<Block label="octoprint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} />
<Block label="octoprint.job_completion" value={`${completion.toFixed(2)}%`} />
</Container>
);
}
return (
<Container service={service}>
<Block label="octoPrint.printer_state" value={printerStats.state.text} />
<Block label="octoPrint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} />
<Block label="octoPrint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} />
<Block label="octoprint.printer_state" value={printerStats.state.text} />
<Block label="octoprint.temp_tool" value={`${printerStats.temperature.tool0.actual} °C`} />
<Block label="octoprint.temp_bed" value={`${printerStats.temperature.bed.actual} °C`} />
</Container>
);
}

View File

@ -33,16 +33,14 @@ export default function Component({ service }) {
const cpu = 100 - parseFloat(cpuIdle);
const memory = activityData.headers[3].match(/Mem: (.+) Active,/)[1];
const wanUpload = interfaceData.interfaces.wan['bytes transmitted'];
const wanDownload = interfaceData.interfaces.wan['bytes received'];
const wan = widget.wan ? interfaceData.interfaces[widget.wan] : interfaceData.interfaces.wan;
return (
<Container service={service}>
<Block label="opnsense.cpu" value={t("common.percent", { value: cpu.toFixed(2) })} />
<Block label="opnsense.memory" value={memory} />
<Block label="opnsense.wanUpload" value={t("common.bytes", { value: wanUpload })} />
<Block label="opnsense.wanDownload" value={t("common.bytes", { value: wanDownload })} />
{wan && <Block label="opnsense.wanUpload" value={t("common.bytes", { value: wan['bytes transmitted'] })} />}
{wan && <Block label="opnsense.wanDownload" value={t("common.bytes", { value: wan['bytes received'] })} />}
</Container>
);
}

View File

@ -25,7 +25,7 @@ import navidrome from "./navidrome/widget";
import nextdns from "./nextdns/widget";
import npm from "./npm/widget";
import nzbget from "./nzbget/widget";
import octoPrint from "./octoPrint/widget";
import octoprint from "./octoprint/widget";
import omada from "./omada/widget";
import ombi from "./ombi/widget";
import opnsense from "./opnsense/widget";
@ -86,7 +86,7 @@ const widgets = {
nextdns,
npm,
nzbget,
octoPrint,
octoprint,
omada,
ombi,
opnsense,