Example Django site for Wagtail openedX - a lightweight CMS for openedX portals.
- docker
- docker-compose
This site is based on the cookiecutter-django template, so further valuable information can also be found in its documentation.
To deploy this site, first go to config/settings/base.py
and set OPENEDX_API_URL
to the URL of the openedX API (without trailing slash) from which the content shall be retrieved.
- Build the stack:
docker-compose -f local.yml build
docker-compose -f local.yml up
- Run the migrations:
docker-compose -f local.yml run django python manage.py migrate
- Create a super user:
docker-compose -f local.yml run django python manage.py createsuperuser
You can now go to https://localhost:8000 to see the live site. To synchronize the courses from the openedX instance defined in the settings, use the view at https://localhost:8000/catalog/sync-courses.
-
Configure a docker-machine environment. For instance, to deploy in DigitalOcean, the following command can be used:
docker-machine create --driver digitalocean --digitalocean-region $DO_REGION \ --digitalocean-image $DO_IMAGE --digitalocean-size $DO_SIZE \ --digitalocean-access-token $DO_TOKEN --engine-install-url=$ENGINE_URL \ $MACHINE_NAME
with the variables set to (feel free to adjust them to suit your use case):
DO_REGION=fra1
DO_IMAGE=ubuntu-18-04-x64
DO_SIZE=s-4vcpu-8gb
DO_TOKEN
is the DigitalOcean personal access token.ENGINE_URL=https://releases.rancher.com/install-docker/19.03.09.sh
MACHINE_NAME=wagtail-openedx-site
-
Point docker to the new machine:
eval $(docker-machine env wagtail-openedx-site)
-
Amend the following production environment variables at
.envs/.production/.django
(remember to keep.envs/.production/.django
out of version control to avoid disclosing secret access keys):- Create a S3-like storage instance and amend the
DJANGO_AWS_ACCESS_KEY_ID
,DJANGO_AWS_STORAGE_BUCKET_NAME
,DJANGO_AWS_S3_REGION_NAME
andDJANGO_AWS_S3_ENDPOINT_URL
. Note that the example settings in this repository are based on DigitalOcean Spaces so you might need to adjust them if you are using another cloud provider. Adjustments in the production settings atconfig/settings/production.py
might also be required. See the documentation ofdjango-storages
for more details about configuring remote storages from different providers. - Set the
DJANGO_SECRET_KEY
,DJANGO_ALLOWED_HOSTS
andWAGTAIL_ADMIN_URL
to some URL-safe cryptographichally strong strings, e.g., using thesecrets.token_urlsafe
function. - Set
DJANGO_ALLOWED_HOSTS
to your production domain(s).
- Create a S3-like storage instance and amend the
-
In the
compose/production/traefik.yml
file, change the line:"Host(`wagtail-openedx.africancitieslab.org`) || Host(`www.wagtail-openedx.africancitieslab.org`)"
for the production domain(s).
-
Build the stack:
docker-compose -f production.yml build docker-compose -f production.yml up -d
-
Run the migrations:
docker-compose -f production.yml run django python manage.py migrate
-
Create a super user:
docker-compose -f production.yml run django python manage.py createsuperuser
To set up a development environment, install the requirements and initialize pre-commit as follows:
pip install -r requirements/local.txt
pre-commit install