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

Dockerize discoreg #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 8000

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

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

ENV PYTHONUNBUFFERED 1

WORKDIR /discoreg

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
```
10 changes: 4 additions & 6 deletions discoreg/discoreg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import dj_database_url
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand All @@ -26,8 +27,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 Expand Up @@ -93,10 +92,9 @@
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
"default": dj_database_url.config(
default="sqlite:///{}".format(os.path.join(BASE_DIR, 'db.sqlite3')),
),
}


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:
- '8000:8000'
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 --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.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
aiohttp
asgiref
async-timeout
attrs
bleach
blinker
certifi
chardet
discord-py
dj-database-url
django
django-heroku
gunicorn
idna
importlib-metadata
jsonpickle
multidict
oauthlib
packaging
psycopg2
pyparsing
pytz
pyyaml
raygun4py
requests
requests-oauthlib
six
sqlparse
urllib3
webencodings
websockets
whitenoise
yarl
zipp
141 changes: 141 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile requirements.in
#
--extra-index-url https://pypi.python.org/simple/
--trusted-host pypi.python.org

aiohttp==3.8.5
# via
# -r requirements.in
# discord-py
aiosignal==1.3.1
# via aiohttp
asgiref==3.7.2
# via
# -r requirements.in
# django
async-timeout==4.0.3
# via
# -r requirements.in
# aiohttp
attrs==23.1.0
# via
# -r requirements.in
# aiohttp
backports-zoneinfo==0.2.1
# via django
bleach==6.0.0
# via -r requirements.in
blinker==1.6.2
# via
# -r requirements.in
# raygun4py
certifi==2023.7.22
# via
# -r requirements.in
# requests
chardet==5.2.0
# via -r requirements.in
charset-normalizer==3.3.0
# via
# aiohttp
# requests
discord-py==2.3.2
# via -r requirements.in
dj-database-url==2.1.0
# via
# -r requirements.in
# django-heroku
django==4.2.5
# via
# -r requirements.in
# dj-database-url
# django-heroku
django-heroku==0.3.1
# via -r requirements.in
frozenlist==1.4.0
# via
# aiohttp
# aiosignal
gunicorn==21.2.0
# via -r requirements.in
idna==3.4
# via
# -r requirements.in
# requests
# yarl
importlib-metadata==6.8.0
# via -r requirements.in
jsonpickle==3.0.2
# via
# -r requirements.in
# raygun4py
multidict==6.0.4
# via
# -r requirements.in
# aiohttp
# yarl
oauthlib==3.2.2
# via
# -r requirements.in
# requests-oauthlib
packaging==23.2
# via
# -r requirements.in
# gunicorn
psycopg2==2.9.8
# via
# -r requirements.in
# django-heroku
pyparsing==3.1.1
# via -r requirements.in
pytz==2023.3.post1
# via -r requirements.in
pyyaml==6.0.1
# via -r requirements.in
raygun4py==4.4.0
# via -r requirements.in
requests==2.31.0
# via
# -r requirements.in
# raygun4py
# requests-oauthlib
requests-oauthlib==1.3.1
# via -r requirements.in
six==1.16.0
# via
# -r requirements.in
# bleach
sqlparse==0.4.4
# via
# -r requirements.in
# django
typing-extensions==4.8.0
# via
# asgiref
# dj-database-url
urllib3==2.0.6
# via
# -r requirements.in
# requests
webencodings==0.5.1
# via
# -r requirements.in
# bleach
websockets==11.0.3
# via -r requirements.in
whitenoise==6.5.0
# via
# -r requirements.in
# django-heroku
yarl==1.9.2
# via
# -r requirements.in
# aiohttp
zipp==3.17.0
# via
# -r requirements.in
# importlib-metadata