Skip to content

Commit

Permalink
Dockerize + Add GitHub Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanC committed Jan 30, 2023
1 parent 1dda628 commit 9b2c7b1
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Credentials
config.json
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci

on:
push:
branches:
- "main"

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/n31l:latest
-
name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
repository: ${{ secrets.DOCKER_HUB_USERNAME }}/n31l
short-description: ${{ github.event.repository.description }}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11.1-slim-bullseye

WORKDIR /n31l

# Install and configure Poetry
# https://github.com/python-poetry/poetry
RUN pip install poetry
RUN poetry config virtualenvs.create false

# Install dependencies
COPY pyproject.toml pyproject.toml
RUN poetry install

COPY . .

CMD [ "python", "n31l.py", "-OO" ]
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# N31L

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/EthanC/N31L/main.yml?branch=main) ![Docker Pulls](https://img.shields.io/docker/pulls/ethanchrisp/n31l?label=Docker%20Pulls) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/ethanchrisp/n31l/latest?label=Docker%20Image%20Size)

N31L is a utilitarian Discord bot for the [Call of Duty server](https://discord.gg/CallofDuty).

<p align="center">
Expand All @@ -15,16 +17,26 @@ Notice: N31L is purpose-built, this means that its functionality is intended onl
- Granular protection against automated raids
- LOTS of animal and food commands

## Installation

N31L requires Python 3.10 or greater. Required dependencies can be found in [`pyproject.toml`](https://github.com/EthanC/Perplex/blob/main/pyproject.toml).
## Setup

Several credentials, including a [Discord bot token](https://discord.com/developers/), [Reddit API key](https://reddit.com/prefs/apps), and more are required.
[Discord API](https://discord.com/developers/) credentials are required for functionality, and a [Discord Webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) is recommended for notifications.

## Usage
### Docker (Recommended)

Open `config_example.json` and provide the configurable values, then save and rename the file to `config.json`.
Modify the following `docker-compose.yml` example file, then run `docker compose up`.

```py
python n31l.py
```yml
version: "3"
services:
n31l:
container_name: n31l
image: ethanchrisp/n31l:latest
```
### Standalone
N31L is built for [Python 3.11](https://www.python.org/) or greater.
1. Install required dependencies using [Poetry](https://python-poetry.org/): `poetry install`
2. Rename `config_example.json` to `config.json`, then provide the configurable variables.
3. Start N31L: `python n31l.py -OO`
2 changes: 1 addition & 1 deletion n31l.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def SetupLogging(config: Dict[str, Any]) -> None:

logger.success("Installed libuv event loop")
except Exception as e:
logger.error(f"Defaulted to asyncio event loop, {e}")
logger.debug(f"Defaulted to asyncio event loop, {e}")

Initialize()
except KeyboardInterrupt:
Expand Down
47 changes: 46 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ notifiers = "^1.3.3"
hikari-tanjun = "^2.11.2"
httpx = "0.23.3"
asyncpraw = "^7.6.1"
uvloop = "0.17.0"

[tool.poetry.dev-dependencies]
pylint = "^2.15.10"
Expand Down

0 comments on commit 9b2c7b1

Please sign in to comment.