diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f49e1b8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +config.yml +node_modules +package-lock.json 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/.gitignore b/.gitignore index 2ef37d3..4525073 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ node_modules/ config-dev.yml package-lock.json +.vscode +node_modules cache.json -.env \ No newline at end of file +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e25f6c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM node:20 + +WORKDIR /app + +COPY . /app + +RUN npm install + +CMD ["node", "index.js"] diff --git a/README.md b/README.md index 1bc9e65..03c89fe 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ PteroStats is a Discord App/Bot designed to check Pterodactyl or Pelican Panel s - [Using Custom Emoji](#using-custom-emoji) - [Blacklist Nodes](#blacklist-nodes) - [Notifier](#notifier) +- - [Docker](#docker) + - [Installation](#installation-1) + - [Docker Compose](#docker-compose) + - [Docker Run](#docker-run) ### Starting the App/Bot 1. [Create your Discord App/Bot](https://discordjs.guide/preparations/adding-your-bot-to-servers.html). @@ -126,11 +130,14 @@ PteroStats is a Discord App/Bot designed to check Pterodactyl or Pelican Panel s Blacklist Config +## Links +======= ### Notifier Get a notification on Discord when your panel or specific nodes are currently down. Notifier Preview + #### Enabling Notifier Open `config.yml` and set `enable` at the notifier configuration to `true` @@ -159,6 +166,33 @@ Open `config.yml` and set `enable` at the notifier configuration to `true` Notifier Config +## 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 +``` + ## Reporting a Bug Enable `log_error` in the `config.yml` file and check the console for the error message. After that, report it to our Discord server at [Support Server](https://discord.znproject.my.id). 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