Skip to content

Commit

Permalink
#M14. Misc cleanup changes and improvements (#151) (adding docker)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefdworschak authored Feb 24, 2021
1 parent e7adc8e commit 0f89acb
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:20.04

RUN apt-get update -y
RUN apt-get install python3 python3-pip libmysqlclient-dev mysql-client vim -y

WORKDIR /hackathon-app
COPY ./requirements.txt /hackathon-app/requirements.txt

RUN pip3 install -r requirements.txt

COPY ./accounts/ /hackathon-app/accounts/
COPY ./assets/ /hackathon-app/assets/
COPY ./custom_slack_provider/ /hackathon-app/custom_slack_provider/
COPY ./hackathon/ /hackathon-app/hackathon/
COPY ./home/ /hackathon-app/home/
COPY ./images/ /hackathon-app/images/
COPY ./main/ /hackathon-app/main/
COPY ./profiles/ /hackathon-app/profiles/
COPY ./resources/ /hackathon-app/resources/
COPY ./showcase/ /hackathon-app/showcase/
COPY ./static/ /hackathon-app/static/
COPY ./submissions/ /hackathon-app/submissions/
COPY ./teams/ /hackathon-app/teams/
COPY ./templates/ /hackathon-app/templates/
COPY ./manage.py /hackathon-app/manage.py

EXPOSE 8000
ENTRYPOINT ["gunicorn", "--workers=5", "--timeout=120", "--access-logfile=-",\
"--bind=0.0.0.0:8000", "--max-requests=1000", "main.wsgi:application"]
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.4"

services:
hackathon-app:
image: hackathon-app
volumes:
- ./staticfiles/:/hackathon-app/staticfiles/
- ./data/:/hackathon-app/data/
environment:
DEVELOPMENT: 1
SECRET_KEY: "your_secret_key_here"
SITE_NAME: "*"
SLACK_ENABLED: "True"
SHOWCASE_SPOTLIGHT_NUMBER: 5
SUPPORT_EMAIL: [email protected]
DBHOST: mysql
DBPORT: 3306
DBNAME: hackathons
DBUSER: hackathon_user
DBPASS: gummyball
entrypoint: ['python3', 'manage.py', 'runserver', '0.0.0.0:8000']
ports:
- "8000:8000"

mysql:
image: docker.io/mysql:5.6.36
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
# Do NOT use for production
environment:
MYSQL_ROOT_PASSWORD: gummyball
MYSQL_DATABASE: hackathons
MYSQL_USER: hackathon_user
MYSQL_PASSWORD: gummyball
volumes:
- ./data/mysql:/var/lib/mysql
2 changes: 1 addition & 1 deletion main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
"NAME": os.path.join(BASE_DIR, "data", "db.sqlite3"),
}
}

Expand Down
29 changes: 29 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
server {
listen 80;
server_name example.com;
location / {
return 301 https://example.com$request_uri;
}

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
}

server {
listen 443 ssl;
server_name example.com;

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

location / {
proxy_pass http://hackathon-app:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
21 changes: 21 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
appdirs==1.4.3
asgiref==3.2.10
backcall==0.2.0
CacheControl==0.12.6
certifi==2020.6.20
chardet==3.0.4
colorama==0.4.3
contextlib2==0.6.0
decorator==4.4.2
defusedxml==0.6.0
distlib==0.3.0
distro==1.4.0
dj-database-url==0.5.0
Django==3.1.3
django-allauth==0.42.0
django-crispy-forms==1.9.2
django-extensions==3.1.0
graphviz==0.16
gunicorn==20.0.4
html5lib==1.0.1
idna==2.10
ipaddr==2.2.0
ipdb==0.13.4
ipython==7.19.0
ipython-genutils==0.2.0
jedi==0.18.0
lockfile==0.12.2
msgpack==0.6.2
mysqlclient==2.0.3
oauthlib==3.1.0
packaging==20.3
parso==0.8.1
pep517==0.8.2
pexpect==4.8.0
pickleshare==0.7.5
progress==1.5
prompt-toolkit==3.0.8
ptyprocess==0.7.0
Pygments==2.7.3
pyparsing==2.4.6
python-dateutil==2.8.1
python-dotenv==0.14.0
python3-openid==3.2.0
pytoml==0.1.21
pytz==2020.1
requests==2.24.0
requests-oauthlib==1.3.0
sentry-sdk==0.10.2
retrying==1.3.3
six==1.15.0
sqlparse==0.3.1
traitlets==5.0.5
urllib3==1.25.10
wcwidth==0.2.5
webencodings==0.5.1
whitenoise==5.2.0
10 changes: 10 additions & 0 deletions scripts/docker_seed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
echo "============================"
echo "Seeding fixtures"
echo "============================"
docker-compose exec hackathon-app python3 manage.py loaddata organisation
docker-compose exec hackathon-app python3 manage.py loaddata accounts
docker-compose exec hackathon-app python3 manage.py loaddata resources
docker-compose exec hackathon-app python3 manage.py loaddata profiles
docker-compose exec hackathon-app python3 manage.py loaddata emailaddresses
docker-compose exec hackathon-app python3 manage.py loaddata hackathons
docker-compose exec hackathon-app python3 manage.py loaddata showcase

0 comments on commit 0f89acb

Please sign in to comment.