From 61153fda06630149147c0432fa2e3faa0a78f9a8 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Sun, 2 Aug 2015 10:49:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=20docker=20=E8=BF=90?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 +++++++++ Procfile | 1 - oj/daocloud_settings.py | 19 +++++++++++++++++++ oj/settings.py | 6 ++++-- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 Dockerfile delete mode 100644 Procfile create mode 100644 oj/daocloud_settings.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..06833ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:2.7 +ENV PYTHONUNBUFFERED 1 +EVN oj_env daocloud +RUN mkdir /var/oj +COPY . /var/oj/ +WORKDIR /var/oj/ +RUN pip install -r requirements.txt +EXPOSE: 8080 +RUN python manage,py runserver 8080 diff --git a/Procfile b/Procfile deleted file mode 100644 index 5174cae..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: gunicorn oj.wsgi:application -b $VCAP_APP_HOST:$VCAP_APP_PORT \ No newline at end of file diff --git a/oj/daocloud_settings.py b/oj/daocloud_settings.py new file mode 100644 index 0000000..a99e009 --- /dev/null +++ b/oj/daocloud_settings.py @@ -0,0 +1,19 @@ +# coding=utf-8 +import os + +LOG_PATH = "LOG/" + +# Database +# https://docs.djangoproject.com/en/1.8/ref/settings/#databases +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'CONN_MAX_AGE': 1, + } +} + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True \ No newline at end of file diff --git a/oj/settings.py b/oj/settings.py index 803e43a..db9ea8f 100644 --- a/oj/settings.py +++ b/oj/settings.py @@ -15,12 +15,14 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ import os # todo 判断运行环境 -ENV = "local" +ENV = os.environ.get("oj_env", "local") if ENV == "local": from .local_settings import * -else: +elif ENV == "server": from .server_settings import * +elif ENV == "daocloud": + from .daocloud_settings import * BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))