Skip to content

Commit

Permalink
Merge pull request #13 from discord-modmail/setup-docker
Browse files Browse the repository at this point in the history
Add Docker Setup
  • Loading branch information
onerandomusername authored Aug 16, 2021
2 parents cc66544 + 5ff2007 commit cd05f52
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ logs

# Configuration
*config.toml

# Custom docker compose override
docker-compose.override.yml
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM python:3.9-slim

# Set pip to have cleaner logs and no saved cache
ENV PIP_NO_CACHE_DIR=false \
POETRY_VIRTUALENVS_CREATE=false

# HACK: Git is required to install a pinned version of discord.py master
# /var/lib/apt/lists is where `apt-get update` downloads are stored, they can be removed
# as they are recreated when package lists are updated and are redundant
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*

# Install poetry
RUN pip install -U poetry

# See https://github.com/python-poetry/poetry/issues/3336
RUN poetry config experimental.new-installer false

# Create the working directory
WORKDIR /modmail

# Copy the source code in last to optimize rebuilding the image
COPY . .

# Install project dependencies
RUN poetry install --no-dev

CMD ["python", "-m", "modmail"]
19 changes: 19 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file can be used to quickly set up the modmail bot

version: "3.7"

x-restart-policy: &restart_policy
restart: unless-stopped

services:
modmail:
<< : *restart_policy
container_name: modmail
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/modmail
env_file:
- .env
tty: true
46 changes: 30 additions & 16 deletions poetry.lock

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

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ aiohttp = { extras = ["speedups"], version = "^3.7.4" }
arrow = "^1.1.1"
colorama = "^0.4.3"
coloredlogs = "^15.0"
"discord.py" = { git = "https://github.com/Rapptz/discord.py.git", rev = "master" }
"discord.py" = { git = "https://github.com/Rapptz/discord.py.git", branch = "master", rev = "1e17b7f"}
environs = { version = "~=9.3.3", optional = true }
pydantic = { version = "^1.8.2", extras = ["dotenv"] }
toml = "^0.10.2"
# HACK: Poetry uses requests to install git dependencies, which are not explicitly installed when `--no-dev`
# is set in docker, and hence is needed to successfully install discord.py from git
requests = ">=2.7.9"

[tool.poetry.extras]
environs = ["environs"]
Expand Down
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ async-timeout==3.0.1; python_full_version >= "3.5.3" and python_version >= "3.6"
attrs==21.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0"
brotlipy==0.7.0; python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0"
cchardet==2.1.7; python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0"
certifi==2021.5.30; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
cffi==1.14.6; python_version >= "3.6"
chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0"
charset-normalizer==2.0.4; python_full_version >= "3.6.0" and python_version >= "3"
colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
coloredlogs==15.0.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
discord.py @ git+https://github.com/Rapptz/discord.py.git@master ; python_full_version >= "3.8.0"
humanfriendly==9.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
idna==3.2; python_version >= "3.6"
idna==3.2; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.5" or python_version >= "3.6"
multidict==5.1.0; python_version >= "3.6" and python_full_version >= "3.8.0" or python_version >= "3.6"
pycares==4.0.0; python_version >= "3.6"
pycparser==2.20; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.4.0"
pydantic==1.8.2; python_full_version >= "3.6.1"
pyreadline==2.1; python_version >= "2.7" and python_full_version < "3.0.0" and sys_platform == "win32" or python_full_version >= "3.5.0" and sys_platform == "win32"
python-dateutil==2.8.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
python-dotenv==0.19.0; python_full_version >= "3.6.1" and python_version >= "3.5"
requests==2.26.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
toml==0.10.2; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
typing-extensions==3.10.0.0; python_version >= "3.6" or python_full_version >= "3.6.1" or python_version >= "3.6" and python_full_version >= "3.8.0"
urllib3==1.26.6; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4"
yarl==1.6.3; python_version >= "3.6" and python_full_version >= "3.8.0" or python_version >= "3.6"

0 comments on commit cd05f52

Please sign in to comment.