Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Docker Image #39

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config.yml
node_modules
package-lock.json
61 changes: 61 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -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 <account>/<repo>
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 }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package-lock.json
.vscode
node_modules
node_modules
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:20

WORKDIR /app

COPY . /app

# Perform clean install
RUN node index.js

CMD ["node", "index.js"]
51 changes: 43 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ PteroStats is a bot designed to check Pterodactyl Panel and Nodes status and pos
<img alt="Example" src="https://i.imgur.com/fzQANo5.gif" width="200"/>

## 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

Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3.3'
services:
pterostats:
volumes:
- ./config.yml:/app/config.yml
container_name: pterostats
image: ghcr.io/hirzidevs/pterostats:latest