From 4c41b501e5857530dd4102d026245fc5b06d688b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoni=20Nu=C3=B1ez=20Romeu?= Date: Wed, 22 Jul 2026 12:59:11 +0200 Subject: [PATCH] Dockerized app --- .dockerignore | 10 ++++++++++ .env.example | 18 ++++++++++++++++++ .gitignore | 3 +++ Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yml | 18 ++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 .dockerignore create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..26fa972 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +.env +data/messages.db +.git +.gitignore +.mimocode +README.md +Dockerfile +docker-compose.yml +.dockerignore diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c85f8ac --- /dev/null +++ b/.env.example @@ -0,0 +1,18 @@ +# Discord Bot Token +# Get this from https://discord.com/developers/applications +DISCORD_TOKEN= + +# Discord Channel IDs to monitor (comma-separated) +DISCORD_CHANNEL_IDS= + +# Channel name mapping (channel_id=name, comma-separated) +CHANNEL_NAMES= + +# Server port (optional, defaults to 8000) +PORT=8000 + +# Base URL for RSS feed links (optional) +BASE_URL=localhost + +# Fetch interval in milliseconds (optional, defaults to 5 minutes) +FETCH_INTERVAL_MS=300000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eed6050 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.env +data/messages.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8f0bf44 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:18-slim AS base +WORKDIR /app + +# Install dumb-init for proper signal handling +RUN apt-get update && apt-get install -y --no-install-recommends dumb-init && rm -rf /var/lib/apt/lists/* + +# Copy dependency manifests first (layer cache) +COPY package.json package-lock.json* ./ +RUN npm ci --omit=dev && npm cache clean --force + +# Copy application code +COPY src/ ./src/ + +# Create data directory for SQLite +RUN mkdir -p /app/data + +EXPOSE 8000 + +USER node + +ENTRYPOINT ["dumb-init", "--"] +CMD ["node", "src/index.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..21ce7c1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +services: + rss-bot: + build: . + container_name: discord-rss-bot + restart: unless-stopped + env_file: .env + ports: + - "8000:8000" + volumes: + - rss-data:/app/data + healthcheck: + test: ["CMD", "node", "-e", "fetch('http://localhost:8000/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"] + interval: 30s + timeout: 5s + retries: 3 + +volumes: + rss-data: