Skip to content

Commit

Permalink
Update codebase to current live version.
Browse files Browse the repository at this point in the history
  • Loading branch information
scragly committed Jul 9, 2021
1 parent 3b2f06a commit 19cd2da
Show file tree
Hide file tree
Showing 23 changed files with 1,448 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ logs
db.sqlite
sessions
.idea
images/
data/
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# define what image we're starting from.
FROM python:3.9-slim

# Set pip config
ENV PIP_NO_CACHE_DIR=false

# Create the working directory
WORKDIR /bot

# Install project dependencies
# - first build tools, because pillow-simd isn't pre-compiled
RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
python3-dev python3-setuptools libtiff5-dev libjpeg-dev libopenjp2-7-dev \
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev \
python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev
RUN pip install -U pillow-simd
# - then normal stuff
COPY requirements.txt ./
RUN pip install -U -r requirements.txt

# Copy the source code across last to optimize image rebuilds on code changes
# (skips all above steps if we need to redo)
COPY . .

# Define the command to run when the container starts
ENTRYPOINT ["python"]
CMD ["-m", "dreaf"]
4 changes: 4 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ verify_ssl = true

[dev-packages]
better-exceptions = "*"
pipenv-to-requirements = "*"
pillow-simd = "*"

[packages]
"discord.py" = "~=1.6.0"
pendulum = "~=2.1.2"
"discord.ext.context" = "*"
everstone = "*"
rapidfuzz = "*"
afkarena = "*"

[requires]
python_version = "3.9"
Expand Down
192 changes: 175 additions & 17 deletions Pipfile.lock

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

28 changes: 19 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
version: "3.7"
version: "3"

# define all containers
services:
postgres:
image: postgres:13-alpine
environment:
- POSTGRES_DB
- POSTGRES_PASSWORD
- POSTGRES_USER
ports:
- 5432:5432
# my bot's container block
dreaf:
# not using an online image, but building from my own Dockerfile locally
build:
context: .
dockerfile: Dockerfile
# these are host -> internal persistent volume mappings, so redeploys don't wipe important data
volumes:
- ./db:/bot/db
- ./logs:/bot/logs
- .:/bot:ro
# psudo tty to emulate normal console usage.
# this is laziness because my bot is still in development and may have print statements instead of logging
tty: true
# tell it a file to get environmental variables from (optional)
env_file:
- .env
11 changes: 11 additions & 0 deletions docker-compose_pg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.7"

services:
postgres:
image: postgres:13-alpine
environment:
- POSTGRES_DB
- POSTGRES_PASSWORD
- POSTGRES_USER
ports:
- 5432:5432
9 changes: 8 additions & 1 deletion dreaf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@

from dreaf.context import ctx

try:
import better_exceptions
except ImportError:
better_exceptions = None

if better_exceptions:
better_exceptions.hook()

__all__ = ('ctx',)

pendulum.set_local_timezone()

debug_flag = True

logging.getLogger().setLevel(logging.DEBUG)
Expand Down
17 changes: 12 additions & 5 deletions dreaf/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

bot = DreafBot()


@bot.check
async def only_dev(ctx):
return ctx.author.id == 174764205927432192


bot.load_extension("dreaf.testing")
bot.load_extension("dreaf.giftcodes")
bot.load_extension("dreaf.players")
bot.load_extension("dreaf.afk_events")
bot.load_extension("dreaf.items")
bot.load_extension("dreaf.reddit")
# bot.load_extension("dreaf.giftcodes")
# bot.load_extension("dreaf.players")
# bot.load_extension("dreaf.afk_events")
# bot.load_extension("dreaf.items")
# bot.load_extension("dreaf.reddit")
# bot.load_extension("dreaf.hero_img")

bot.run()
Loading

0 comments on commit 19cd2da

Please sign in to comment.