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

Add support for running in Heroku #398

Merged
merged 2 commits into from
Apr 18, 2020
Merged
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ RUN apk update && \
pip install pipenv

ADD Pipfile Pipfile.lock ./
RUN apk add --no-cache mariadb-connector-c-dev && \
RUN apk add --no-cache mariadb-connector-c-dev libpq && \
apk add --no-cache --virtual _build-deps \
build-base mariadb-dev libjpeg-turbo-dev zlib-dev py-gevent libffi-dev && \
build-base mariadb-dev postgresql-dev libjpeg-turbo-dev zlib-dev py-gevent libffi-dev && \
pipenv install --deploy --system && \
apk del _build-deps

Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ future = "*"
addict = "*"
kegbot-api = "*"
gevent = "*"
psycopg2 = "*"

[scripts]
kegbot = "python bin/kegbot"
Expand Down
33 changes: 26 additions & 7 deletions Pipfile.lock

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

4 changes: 2 additions & 2 deletions pykeg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ def is_setup():
Setting('KEGBOT_IN_DOCKER', False, typefn=boolstr)
Setting('KEGBOT_SECRET_KEY', 'not-configured')
Setting('KEGBOT_SETUP_ENABLED', False, typefn=boolstr)
Setting('KEGBOT_DATABASE_URL', 'mysql://root@localhost/kegbot')
Setting('KEGBOT_REDIS_URL', 'redis://localhost:6379/0')
Setting('KEGBOT_DATABASE_URL', os.getenv('DATABASE_URL', 'mysql://root@localhost/kegbot'))
Setting('KEGBOT_REDIS_URL', os.getenv('REDIS_URL', 'redis://localhost:6379/0'))
8 changes: 7 additions & 1 deletion pykeg/web/gunicorn_conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import multiprocessing
import pkg_resources
import sys
import os

BANNER = """
██╗ ██╗███████╗ ██████╗ ██████╗ ██████╗ ████████╗
Expand All @@ -17,7 +18,12 @@ def get_version():
except pkg_resources.DistributionNotFound:
return '0.0.0'

bind = "0.0.0.0:8000"
if os.getenv('KEGBOT_IN_HEROKU') and os.getenv('PORT'):
# Necessary on Heroku, which doesn't respect EXPOSE :-\
bind = "0.0.0.0:{}".format(int(os.getenv('PORT')))
else:
bind = "0.0.0.0:8000"

worker_class = "gevent"
workers = multiprocessing.cpu_count() * 2 + 1

Expand Down