diff --git a/README.md b/README.md index 7bbacd4..3d6e56a 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Open a python shell in the lms or the cms: ## TODO - Make sure that secret keys are not shared with the entire world +- Don't duplicate args between containers - Add arguments to set domain name, platform name, etc. - Add documentation on host Nginx - Better readme diff --git a/docker-compose.yml b/docker-compose.yml index a307509..3971e2f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,11 @@ services: - ./data/mysql:/var/lib/mysql nginx: - build: ./nginx + build: + context: ./nginx + args: + lms_host: learn.overhang.io + cms_host: studio.learn.overhang.io #restart: on-failure ports: - "8800:80" @@ -52,7 +56,10 @@ services: build: context: ./edxapp args: + lms_host: learn.overhang.io + cms_host: studio.learn.overhang.io service_variant: lms + secret_key: "12UyBHiBWxcPT1NP4prP5QhHc" #restart: on-failure volumes: - ./data/edxapp:/openedx/data @@ -67,7 +74,10 @@ services: build: context: ./edxapp args: + lms_host: learn.overhang.io + cms_host: studio.learn.overhang.io service_variant: cms + secret_key: "12UyBHiBWxcPT1NP4prP5QhHc" #restart: on-failure volumes: - ./data/edxapp:/openedx/data @@ -81,7 +91,10 @@ services: build: context: ./edxapp args: + lms_host: learn.overhang.io + cms_host: studio.learn.overhang.io service_variant: lms + secret_key: "12UyBHiBWxcPT1NP4prP5QhHc" command: ./manage.py lms --settings=production celery worker --loglevel=info --hostname=edx.lms.core.default.%%h --maxtasksperchild 100 environment: C_FORCE_ROOT: "1" # run celery tasks as root #nofear diff --git a/edxapp/Dockerfile b/edxapp/Dockerfile index 2f96345..b1d1363 100644 --- a/edxapp/Dockerfile +++ b/edxapp/Dockerfile @@ -34,22 +34,35 @@ RUN pip install -r requirements/edx/local.txt RUN pip install -r requirements/edx/base.txt RUN pip install -r requirements/edx/post.txt RUN pip install -r requirements/edx/paver.txt +# TODO install ced from pip +RUN curl https://raw.githubusercontent.com/regisb/ced/v0.2/ced/ced > /usr/local/bin/ced +RUN chmod a+x /usr/local/bin/ced # Finish requirements install RUN paver install_prereqs -# Copy configuration files -COPY ./config/lms.env.json /openedx/ -COPY ./config/cms.env.json /openedx/ -COPY ./config/lms.auth.json /openedx/ -COPY ./config/cms.auth.json /openedx/ -COPY ./config/production_lms.py /openedx/edx-platform/lms/envs/production.py -COPY ./config/production_cms.py /openedx/edx-platform/cms/envs/production.py - -############ End of code common to lms & cms - +ARG lms_host=localhost:8000 +ARG cms_host=localhost:8000 +ARG platform_name="My Ginkgo Open edX" # service variang is "lms" or "cms" ARG service_variant +ARG secret_key + +# Generate configuration files +ENV LMS_HOST=$lms_host CMS_HOST=$cms_host PLATFORM_NAME=$platform_name SECRET_KEY=$secret_key +COPY ./config/production_lms.py /openedx/edx-platform/lms/envs/production.py +COPY ./config/production_cms.py /openedx/edx-platform/cms/envs/production.py +COPY ./config/lms.env.json.templ /openedx/ +COPY ./config/cms.env.json.templ /openedx/ +COPY ./config/lms.auth.json.templ /openedx/ +COPY ./config/cms.auth.json.templ /openedx/ +RUN ced /openedx/lms.env.json.templ -o /openedx/lms.env.json +RUN ced /openedx/cms.env.json.templ -o /openedx/cms.env.json +RUN ced /openedx/lms.auth.json.templ -o /openedx/lms.auth.json +RUN ced /openedx/cms.auth.json.templ -o /openedx/cms.auth.json + + +############ End of code common to lms & cms # Configure environment ENV DJANGO_SETTINGS_MODULE ${service_variant}.envs.production diff --git a/edxapp/config/cms.auth.json b/edxapp/config/cms.auth.json.templ similarity index 92% rename from edxapp/config/cms.auth.json rename to edxapp/config/cms.auth.json.templ index d3c3c8f..879c7fa 100644 --- a/edxapp/config/cms.auth.json +++ b/edxapp/config/cms.auth.json.templ @@ -1,5 +1,5 @@ { - "SECRET_KEY": "7i#nri2i@--brp0sri9qf@ewlj1qxghv0%af$sk4ntn9pv$8t#", + "SECRET_KEY": "${SECRET_KEY}", "AWS_ACCESS_KEY_ID": "", "AWS_SECRET_ACCESS_KEY": "", "XQUEUE_INTERFACE": { diff --git a/edxapp/config/cms.env.json b/edxapp/config/cms.env.json.templ similarity index 87% rename from edxapp/config/cms.env.json rename to edxapp/config/cms.env.json.templ index 339688b..7c7b415 100644 --- a/edxapp/config/cms.env.json +++ b/edxapp/config/cms.env.json.templ @@ -1,17 +1,17 @@ { - "SITE_NAME": "studio.openedxdemo.overhang.io", + "SITE_NAME": "${CMS_HOST}", "BOOK_URL": "", "LOG_DIR": "/openedx/data/logs", "LOGGING_ENV": "sandbox", "OAUTH_OIDC_ISSUER": "http://localhost:8000/oauth2", - "PLATFORM_NAME": "Open edX Studio Demo Site (Ginkgo)", + "PLATFORM_NAME": "${PLATFORM_NAME}", "FEATURES": { "PREVIEW_LMS_BASE": "localhost:8000" }, - "LMS_ROOT_URL": "http://openedxdemo.overhang.io", - "CMS_ROOT_URL": "http://studio.openedxdemo.overhang.io", - "CMS_BASE": "studio.openedxdemo.overhang.io", - "LMS_BASE": "openedxdemo.overhang.io", + "LMS_ROOT_URL": "http://${LMS_HOST}", + "CMS_ROOT_URL": "http://${CMS_HOST}", + "CMS_BASE": "${CMS_HOST}", + "LMS_BASE": "${LMS_HOST}", "CELERY_BROKER_HOSTNAME": "rabbitmq", "CELERY_BROKER_TRANSPORT": "amqp", "MEDIA_ROOT": "/openedx/data/uploads/", diff --git a/edxapp/config/lms.auth.json b/edxapp/config/lms.auth.json.templ similarity index 92% rename from edxapp/config/lms.auth.json rename to edxapp/config/lms.auth.json.templ index d3c3c8f..879c7fa 100644 --- a/edxapp/config/lms.auth.json +++ b/edxapp/config/lms.auth.json.templ @@ -1,5 +1,5 @@ { - "SECRET_KEY": "7i#nri2i@--brp0sri9qf@ewlj1qxghv0%af$sk4ntn9pv$8t#", + "SECRET_KEY": "${SECRET_KEY}", "AWS_ACCESS_KEY_ID": "", "AWS_SECRET_ACCESS_KEY": "", "XQUEUE_INTERFACE": { diff --git a/edxapp/config/lms.env.json b/edxapp/config/lms.env.json.templ similarity index 87% rename from edxapp/config/lms.env.json rename to edxapp/config/lms.env.json.templ index 432715a..604a7c5 100644 --- a/edxapp/config/lms.env.json +++ b/edxapp/config/lms.env.json.templ @@ -1,16 +1,16 @@ { - "SITE_NAME": "openedxdemo.overhang.io", + "SITE_NAME": "${LMS_HOST}", "BOOK_URL": "", "LOG_DIR": "/openedx/data/logs", "LOGGING_ENV": "sandbox", "OAUTH_OIDC_ISSUER": "http://localhost:8000/oauth2", - "PLATFORM_NAME": "Open edX Demo Site (Ginkgo)", + "PLATFORM_NAME": "${PLATFORM_NAME}", "FEATURES": { - "PREVIEW_LMS_BASE": "openedxdemo.overhang.io" + "PREVIEW_LMS_BASE": "${LMS_HOST}" }, - "LMS_ROOT_URL": "http://openedxdemo.overhang.io", - "CMS_ROOT_URL": "http://studio.openedxdemo.overhang.io", - "CMS_BASE": "studio.openedxdemo.overhang.io", + "LMS_ROOT_URL": "http://${LMS_HOST}", + "CMS_ROOT_URL": "http://${CMS_HOST}", + "CMS_BASE": "${CMS_HOST}", "LMS_BASE": "openedxdemo.overhang.io", "CELERY_BROKER_HOSTNAME": "rabbitmq", "CELERY_BROKER_TRANSPORT": "amqp", diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 257ace0..77104e5 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,6 +1,17 @@ FROM nginx:1.13 - VOLUME /openedx/data -COPY ./config/lms.conf /etc/nginx/conf.d/lms.conf -COPY ./config/cms.conf /etc/nginx/conf.d/cms.conf +# TODO install ced from pip +RUN apt update +RUN apt install -y curl python +RUN curl https://raw.githubusercontent.com/regisb/ced/v0.2/ced/ced > /usr/local/bin/ced +RUN chmod a+x /usr/local/bin/ced + +ARG lms_host=localhost +ARG cms_host=studio.$lms_host +ENV LMS_HOST=$lms_host CMS_HOST=$cms_host + +COPY ./config/lms.conf.templ /etc/nginx/conf.d/lms.conf.templ +RUN ced -o /etc/nginx/conf.d/lms.conf -d £ /etc/nginx/conf.d/lms.conf.templ +COPY ./config/cms.conf.templ /etc/nginx/conf.d/cms.conf.templ +RUN ced -o /etc/nginx/conf.d/cms.conf -d £ /etc/nginx/conf.d/cms.conf.templ diff --git a/nginx/config/cms.conf b/nginx/config/cms.conf.templ similarity index 97% rename from nginx/config/cms.conf rename to nginx/config/cms.conf.templ index bd400b9..150c530 100644 --- a/nginx/config/cms.conf +++ b/nginx/config/cms.conf.templ @@ -4,7 +4,7 @@ upstream cms-backend { server { listen 80; - server_name studio.openedxdemo.overhang.io; + server_name £{CMS_HOST}; # Prevent invalid display courseware in IE 10+ with high privacy settings add_header P3P 'CP="Open edX does not have a P3P policy."'; diff --git a/nginx/config/lms.conf b/nginx/config/lms.conf.templ similarity index 98% rename from nginx/config/lms.conf rename to nginx/config/lms.conf.templ index e819603..7efe211 100644 --- a/nginx/config/lms.conf +++ b/nginx/config/lms.conf.templ @@ -4,7 +4,7 @@ upstream lms-backend { server { listen 80; - server_name openedxdemo.overhang.io; + server_name £{LMS_HOST}; # Prevent invalid display courseware in IE 10+ with high privacy settings add_header P3P 'CP="Open edX does not have a P3P policy."';