diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..976bfd2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM centos:7 + + +RUN rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum -y install python36 python36-pip dos2unix git +RUN yum -y install gcc gcc-c++ make libcurl-devel + +# workdir and user +WORKDIR /OopsyPad +# USER 0 + +COPY . . + +# Get breakpad inside container +RUN rm -rf ./3rdparty/breakpad/* +RUN git submodule update --init --recursive + +# Install dependencies +RUN dos2unix ./3rdparty/build.sh +RUN ./3rdparty/build.sh + +# install OopsyPad +RUN python3 -m pip install . + +EXPOSE 8000 + +ENV LC_ALL=en_US.utf-8 +ENV LANG=en_US.utf-8 + +ENV OOPSY_HOST=http://localhost:8000 + +RUN dos2unix /OopsyPad/start.sh +ENTRYPOINT ["/bin/sh"] +CMD ["/OopsyPad/start.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e2ede0d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +# Note: Requires docker-comopse 1.10+. +version: "2" +services: + + mongo: + image: mongo + ports: + - "27017:27017" + + oopsypad: + build: + context: . + dockerfile: ./Dockerfile + image: oopsypad + ports: + - "8000:8000" + environment: + - MONGODB_HOST=mongo + - CELERY_BROKER_URL=mongodb://mongo + - CELERY_RESULT_BACKEND=mongodb://mongo + depends_on: + - mongo \ No newline at end of file diff --git a/oopsypad/server/config.py b/oopsypad/server/config.py index 8e494a3..01cc74d 100644 --- a/oopsypad/server/config.py +++ b/oopsypad/server/config.py @@ -8,6 +8,7 @@ PROD: 'oopsy_pad' } +mongo_host = os.environ.get('MONGODB_HOST', 'localhost') class Config: SECRET_KEY = 'dev' @@ -27,8 +28,8 @@ class Config: DUMPS_DIR = os.path.join(ROOT_DIR, 'dumps') SYMFILES_DIR = os.path.join(ROOT_DIR, 'symbols') - CELERY_BROKER_URL = 'redis://localhost:6379/1' - CELERY_RESULT_BACKEND = 'redis://localhost:6379/1' + CELERY_BROKER_URL = os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/1') + CELERY_RESULT_BACKEND = os.environ.get('CELERY_RESULT_BACKEND', 'redis://localhost:6379/1') SECURITY_PASSWORD_HASH = 'sha512_crypt' SECURITY_PASSWORD_SALT = SECRET_KEY @@ -44,12 +45,14 @@ class Config: ENABLE_SENTRY = False SENTRY_DSN = '' - class DevConfig(Config): DEBUG = True CREATE_TEST_USERS = True - MONGODB_SETTINGS = {'DB': DB_NAMES[DEV]} + MONGODB_SETTINGS = { + 'DB': DB_NAMES[DEV], + 'HOST': mongo_host + } class TestConfig(Config): @@ -57,7 +60,10 @@ class TestConfig(Config): TESTING = True CREATE_TEST_USERS = True - MONGODB_SETTINGS = {'DB': DB_NAMES[TEST]} + MONGODB_SETTINGS = { + 'DB': DB_NAMES[TEST], + 'HOST': mongo_host + } LIVESERVER_PORT = 8000 @@ -65,7 +71,10 @@ class TestConfig(Config): class ProdConfig(Config): DEBUG = False - MONGODB_SETTINGS = {'DB': DB_NAMES[PROD]} + MONGODB_SETTINGS = { + 'DB': DB_NAMES[PROD], + 'HOST': mongo_host + } ENABLE_SENTRY = True diff --git a/setup.py b/setup.py index 1b7f616..a5df199 100644 --- a/setup.py +++ b/setup.py @@ -17,11 +17,12 @@ 'flask-httpauth', 'flask-security', 'redis', - 'celery', + 'celery==4.4.7', 'python-dateutil', 'gunicorn', 'requests', 'raven', + 'email_validator', ], tests_require=[ 'selenium', diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..c30ceb7 --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e + +oopsy_celery_worker run +oopsy_run_server --host 0.0.0.0 --port 8000 +oopsy_celery_worker stop \ No newline at end of file