From f77e64e31acc478520e25b8a3369b7968417811f Mon Sep 17 00:00:00 2001 From: Nard Theo Date: Mon, 20 May 2024 12:03:56 +0200 Subject: [PATCH 1/3] feat: Dockerfile + workflow --- .dockerignore | 1 + .github/workflows/docker-publish.yml | 61 ++++++++++++++++++++++++++++ Dockerfile | 12 ++++++ 3 files changed, 74 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1d3ed4c --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +config.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..f2918e1 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,61 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ master ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ main ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a77bd2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:22.2.0 + +WORKDIR /app + +COPY package.json /app/package.json +# COPY package-lock.json /app/package-lock.json + +RUN npm install + +COPY . /app + +CMD ["npm", "start"] \ No newline at end of file From 6a804ff2d5049e7618d2260e539f7ff425092f17 Mon Sep 17 00:00:00 2001 From: Nard Theo Date: Mon, 20 May 2024 12:32:13 +0200 Subject: [PATCH 2/3] feat: docker images --- .dockerignore | 2 ++ .gitignore | 2 +- Dockerfile | 12 +++++------ README.md | 51 ++++++++++++++++++++++++++++++++++++++-------- docker-compose.yml | 7 +++++++ 5 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore index 1d3ed4c..f49e1b8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ config.yml +node_modules +package-lock.json diff --git a/.gitignore b/.gitignore index d225ef6..6134a9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ package-lock.json .vscode -node_modules \ No newline at end of file +node_modules diff --git a/Dockerfile b/Dockerfile index 7a77bd2..11dce54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ -FROM node:22.2.0 +FROM node:20 WORKDIR /app -COPY package.json /app/package.json -# COPY package-lock.json /app/package-lock.json - -RUN npm install - COPY . /app -CMD ["npm", "start"] \ No newline at end of file +# Perform clean install +RUN node index.js + +CMD ["node", "index.js"] diff --git a/README.md b/README.md index 69c72b8..26e966a 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,22 @@ PteroStats is a bot designed to check Pterodactyl Panel and Nodes status and pos Example ## Installation -1. [Getting API key from pterodactyl](#getting-apikey-from-pterodactyl) -2. [Creating Discord Bot](#creating-discord-bot) -3. [Inviting Discord Bot](#inviting-discord-bot) -4. [Getting Channel ID](#getting-channel-id) -5. [Starting bot](#starting-bot) - -- [Using Custom Emoji](#using-custom-emoji) -- [Blacklist Nodes](#blacklist-nodes) +- [Introduction](#introduction) +- [Example](#example) +- [Installation](#installation) + - [Getting API key from pterodactyl](#getting-api-key-from-pterodactyl) + - [Creating Discord Bot](#creating-discord-bot) + - [Inviting Discord Bot](#inviting-discord-bot) + - [Getting Channel ID](#getting-channel-id) + - [Starting bot](#starting-bot) + - [Using Custom Emoji](#using-custom-emoji) + - [Blacklist Nodes](#blacklist-nodes) +- [The node is online but the embed is read as offline](#the-node-is-online-but-the-embed-is-read-as-offline) +- [Docker](#docker) + - [Installation](#installation-1) + - [Docker Compose](#docker-compose) + - [Docker Run](#docker-run) +- [Links](#links) ### Getting API key from pterodactyl @@ -116,6 +124,33 @@ You can add more than one node in the blacklist If you having this issue, you can enable `log_error` on the config file and report it to our discord server at [Support Server](https://discord.gg/zv6maQRah3) +## Docker + +This is a guide to run the bot using docker (alternative way to run the bot) + +### Installation + +```bash +curl -fsSL https://get.docker.com | sh +``` + +### Docker Compose + +Copy the `docker-compose.yml` file to your server and run `docker compose pull` +Copy the `config.yml` file at the same directory as the `docker-compose.yml` file and configure it (refer to the [installation](#installation) section) + +```bash +docker compose up -d +docker compose logs -f pterostats +``` + +### Docker Run + +```bash +docker run -d --name pterostats -v $(pwd)/config.yml:/app/config.yml ghcr.io/hirzidevs/pterostats:latest +docker logs -f pterostats +``` + ## Links - [PteroStats DiscordJS v13](https://github.com/HirziDevs/PteroStats/tree/3d0512c3323ecf079101104c7ecf3c94d265e298) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..99a83ae --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3.3' +services: + pterostats: + volumes: + - ./config.yml:/app/config.yml + container_name: pterostats + image: ghcr.io/hirzidevs/pterostats:latest From 22e82372bc9ce58e0de92e01afb374f590418ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nard=20Th=C3=A9o?= <58373303+PandeoF1@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:05:38 +0200 Subject: [PATCH 3/3] fix: Adapt to new pterostats --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11dce54..e25f6c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,6 @@ WORKDIR /app COPY . /app -# Perform clean install -RUN node index.js +RUN npm install CMD ["node", "index.js"]