Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.8

ENV PYTHONUNBUFFERED 1

WORKDIR /discoreg
EXPOSE 80
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be running this behind nginx, so can we use 8000 (or whatever gunicorn's default port is) here?


COPY requirements.txt /discoreg
RUN pip3 install -r requirements.txt --no-cache-dir
COPY . /discoreg

ENTRYPOINT ["/discoreg/docker-entrypoint.sh"]
CMD ["sh"]
13 changes: 13 additions & 0 deletions Dockerfile.nextupbot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.8

ENV PYTHONUNBUFFERED 1

WORKDIR /discoreg
EXPOSE 80

COPY requirements.txt /discoreg
RUN pip3 install -r requirements.txt --no-cache-dir
COPY . /discoreg

ENTRYPOINT ["python3"]
CMD ["discoreg/manage.py", "nextupbot"]
22 changes: 0 additions & 22 deletions Pipfile

This file was deleted.

549 changes: 0 additions & 549 deletions Pipfile.lock

This file was deleted.

3 changes: 0 additions & 3 deletions Procfile

This file was deleted.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# discoreg

A Django app to manage invites to a Discord server based on conference registrations.

# Building the docker image(s)

Ensure Docker Deskop is running locally and run this command. It will build the image and tag it with the name discoreg. (This will only build the web server)

```
docker build . -t discoreg
```

To build the nextupbot image, point to the specific Dockerfile for it

```
docker build . -t nextupbot -f Dockerfile.nextupbot
```

# Running disoreg with Docker Compose locally after building the images

```
docker-compose up --build
```
2 changes: 0 additions & 2 deletions discoreg/discoreg/settings.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably make the database configurable (e.g. with https://github.com/jazzband/dj-database-url) along with this change. In the mean time, I'll likely mount the path to the database as a docker volume to make sure it persists to disk.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
DEBUG = os.environ.get("DEBUG", False) == "1"

ALLOWED_HOSTS = [
"pygotham-chat-staging.herokuapp.com",
"pygotham-chat-production.herokuapp.com",
"chat.pygotham.tv",
"tylerdave.ngrok.io",
"localhost",
Expand Down
2 changes: 1 addition & 1 deletion discoreg/registrations/templates/registrations/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="title">Join PyGotham TV on Discord!</h1>
<h2 class="subtitle">1. Register for PyGotham TV</h2>
<p>To be added to our Discord server you need to register for the conference using the same email address as your Discord account.
<p>Already registered? Skip to step 2.</p>
<p><a href="https://2021.pygotham.tv/registration/" target="_blank" class="button is-link">Register for PyGotham TV</a></p>
<p><a href="https://2023.pygotham.tv/registration/" target="_blank" class="button is-link">Register for PyGotham TV</a></p>
</div>
<div class="box">
<h2 class="subtitle">2. Log in to Discord</h2>
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'

services:
web:
image: discoreg
build:
context: ./discoreg
dockerfile: Dockerfile
container_name: discoreg
ports:
- '80:80'
env_file:
- example.env
worker:
image: nextupbot
build:
context: ./discoreg
dockerfile: Dockerfile.nextupbot
container_name: nextupbot
env_file:
- example.env
13 changes: 13 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Collect static files
echo "Collect static files"
python3 discoreg/manage.py collectstatic --noinput

# Apply database migrations
echo "Apply database migrations"
python3 discoreg/manage.py migrate

# Start server
echo "Starting server"
gunicorn --pythonpath discoreg discoreg.wsgi --bind 0.0.0.0:80 --log-file -
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DJANGO_SECRET_KEY="foo"
DISCORD_CLIENT_ID="REPLACE WITH CLIENT_ID"
DISCORD_CLIENT_SECRET="REPLACE WITH CLIENT_SECRET"
DISCORD_BOT_TOKEN="REPLACE WITH BOT_TOKEN"
Expand Down
34 changes: 34 additions & 0 deletions requirements.txt
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use something like pip-compile to retain the separation of top-level and fully pinned requirements? Happy to contribute this change to the PR myself, just want to make sure we don't lose that information and the ability to reasonably upgrade dependencies going forward.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
aiohttp==3.6.2
asgiref==3.2.10
async-timeout==3.0.1
attrs==19.3.0
bleach==3.1.5
blinker==1.4
certifi==2020.6.20
chardet==3.0.4
discord-py==1.3.4
dj-database-url==0.5.0
django==3.0.8
django-heroku==0.3.1
gunicorn==20.0.4
idna==2.10
importlib-metadata==1.7.0
jsonpickle==1.4.1
multidict==4.7.6
oauthlib==3.1.0
packaging==20.4
psycopg2==2.8.5
pyparsing==2.4.7
pytz==2020.1
pyyaml==5.3.1
raygun4py==4.3.0
requests==2.24.0
requests-oauthlib==1.3.0
six==1.15.0
sqlparse==0.3.1
urllib3==1.25.10
webencodings==0.5.1
websockets==8.1
whitenoise==5.1.0
yarl==1.4.2
zipp==3.1.0