-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a461761
commit bed387c
Showing
13 changed files
with
76 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
FROM node:20-alpine AS build | ||
WORKDIR /usr/src/app | ||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
|
||
# Production stage | ||
FROM node:20-alpine | ||
FROM oven/bun:latest AS base | ||
WORKDIR /usr/src/app | ||
|
||
# Install su-exec | ||
RUN apk add --no-cache su-exec | ||
|
||
# Copy only the necessary files from the build stage | ||
COPY --from=build /usr/src/app/package*.json ./ | ||
COPY --from=build /usr/src/app/node_modules ./node_modules | ||
COPY --from=build /usr/src/app/dist ./ | ||
|
||
# Create /data directory | ||
RUN mkdir -p /data | ||
# install dependencies into temp directory | ||
# this will cache them and speed up future builds | ||
FROM base AS install | ||
RUN mkdir -p /temp/dev | ||
COPY package.json bun.lockb /temp/dev/ | ||
RUN cd /temp/dev && bun install --frozen-lockfile | ||
|
||
# install with --production (exclude devDependencies) | ||
RUN mkdir -p /temp/prod | ||
COPY package.json bun.lockb /temp/prod/ | ||
RUN cd /temp/prod && bun install --frozen-lockfile --production | ||
|
||
# make node_modules readable for all users | ||
# see https://github.com/oven-sh/bun/issues/10331 why this is needed | ||
RUN chmod -R a+r /temp/prod/node_modules | ||
|
||
# copy node_modules from temp directory | ||
# then copy all (non-ignored) project files into the image | ||
FROM base AS prerelease | ||
COPY --from=install /temp/dev/node_modules node_modules | ||
COPY . . | ||
|
||
# Create symbolic link for easier volume mount | ||
RUN ln -sfn /data /usr/src/app/data | ||
ENV NODE_ENV=production | ||
|
||
# Define environment variables for user and group IDs (optional) | ||
ENV PUID= | ||
ENV PGID= | ||
# copy production dependencies and source code into final image | ||
FROM oven/bun:distroless AS release | ||
WORKDIR / | ||
|
||
# Copy entrypoint script | ||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
COPY --from=install /temp/prod/node_modules node_modules | ||
COPY --from=prerelease /usr/src/app/src . | ||
COPY --from=prerelease /usr/src/app/package.json . | ||
|
||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
CMD ["node", "app.js"] | ||
ENTRYPOINT [ "bun", "run", "app.ts", "--target=node" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
# Bahnhof Watchdog | ||
|
||
Bahnhof Watchdog is a Node.js service that periodically checks for current and planned outages in your area from the ISP named Bahnhof. It also checks if your current subscription is priced higher than what is listed on their website. Notifications are sent via a Discord webhook or via email (Gmail only) if any issues are found. | ||
Bahnhof Watchdog is a Bun-based background service that periodically checks for current and planned outages in your area from the ISP named Bahnhof. It also checks if your current subscription is priced higher than what is listed on their website. Notifications are sent through a Discord webhook or by email (Gmail only) if any issues are found. | ||
|
||
## Features | ||
|
||
|
@@ -58,6 +58,7 @@ MAIL_RECEIVER="[email protected]" | |
bahnhof-watchdog: | ||
container_name: bahnhof-watchdog | ||
image: musenkishi/bahnhof-watchdog:latest | ||
user: ${PUID}:${PGID} # optional | ||
volumes: | ||
- data:/data | ||
restart: unless-stopped | ||
|
@@ -85,6 +86,10 @@ MAIL_RECEIVER="[email protected]" | |
```bash | ||
docker run --env-file .env musenkishi/bahnhof-watchdog:latest | ||
``` | ||
3. **Alternative: Run with specific user/group** | ||
```bash | ||
docker run --user 1000:1000 --env-file .env musenkishi/bahnhof-watchdog:latest | ||
``` | ||
|
||
#### Building the Image Locally | ||
|
||
|
@@ -121,21 +126,15 @@ MAIL_RECEIVER="[email protected]" | |
2. **Install dependencies**: | ||
|
||
```bash | ||
npm install | ||
bun install | ||
``` | ||
|
||
3. **Create a `.env` file** in the root directory and add your environment variables as described above. | ||
|
||
4. **Build the project** | ||
|
||
```bash | ||
tsc | ||
``` | ||
|
||
5. **Run the service**: | ||
4. **Run the service**: | ||
|
||
```bash | ||
node dist/app.js | ||
bun start | ||
``` | ||
|
||
## Usage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { loadFile, syncFile } from "../api/file" | ||
import { loadFile, writeFile } from "../api/file" | ||
|
||
const FILENAME_VERSION = ".version" | ||
const VERSION = "1.0.0" | ||
const VERSION = "1.1.0" | ||
|
||
export const checkVersion = async () => { | ||
const existingVerFile = await loadFile(FILENAME_VERSION) | ||
if (existingVerFile != VERSION) { | ||
// Handle any breaking changes in future upgrades here | ||
} | ||
syncFile(FILENAME_VERSION, VERSION) | ||
writeFile(FILENAME_VERSION, VERSION) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"esModuleInterop": true, | ||
"target": "es6", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"outDir": "dist" | ||
}, | ||
"lib": ["es2015"] | ||
"lib": ["ESNext"], | ||
"module": "NodeNext", | ||
"target": "esnext", | ||
"types": ["bun-types"], | ||
"moduleResolution": "NodeNext" | ||
} | ||
} |
Oops, something went wrong.