Skip to content

Commit 1f7da9c

Browse files
committed
Updated micromasters documentation
1 parent e71ad7a commit 1f7da9c

File tree

4 files changed

+117
-110
lines changed

4 files changed

+117
-110
lines changed

.rsync-ignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
Makefile
66
README.rst
77
.DS_Store
8+
.idea/

Makefile

-6
This file was deleted.

README.md

+111-104
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,41 @@
11
# Micromasters
22
Portal for learners and course teams to access MITx Micromasters programs
33

4-
## Getting Started
4+
## Major Dependencies
5+
- Docker
6+
- OSX recommended install method: [Download from Docker website](https://docs.docker.com/mac/)
7+
- docker-compose
8+
- Recommended install: pip `pip install docker-compose`
9+
- Virtualbox (https://www.virtualbox.org/wiki/Downloads)
510

6-
Although you can run Micromasters locally with a default sqlite database after
7-
installing the ``requirements.txt`` file, the recommended way is to
8-
use [Docker](https://www.docker.io). Install Docker, then install
9-
``docker-compose`` and run the app:
11+
## (OSX only) Getting your machine Docker-ready
1012

11-
pip install docker-compose
12-
docker-compose up
13+
#### Create your docker container:
1314

14-
### (OSX only) Create your docker machine:
15-
16-
docker-machine create default
17-
docker-machine start default
18-
docker-machine env default
19-
eval "$(docker-machine env default)"
20-
21-
These commands create a Docker container named ``default``, start the
15+
The following commands create a Docker machine named ``mm``, start the
2216
container, and configure environment variables to facilitate communication
23-
with the ``edX`` instance.
24-
25-
26-
This will set up a near production-ready containerized development
27-
environment that runs migrations, with the Django development server
28-
running on port ``8079``.
29-
30-
To run one-off commands, like shell, you can run:
17+
with the edX instance.
3118

32-
docker-compose run web python manage.py shell
19+
docker-machine create --driver virtualbox mm
20+
docker-machine start mm
21+
# 'docker-machine env (machine)' prints export commands for important environment variables
22+
eval "$(docker-machine env mm)"
3323

34-
or to create root user:
24+
#### Enable file syncing between the host machine and Docker:
3525

36-
docker-compose run web python manage.py createsuperuser
26+
Due to file notification issues using Docker in OSX, development is more
27+
efficient if you install [docker-osx-dev](https://github.com/brikis98/docker-osx-dev).
28+
This synchronizes host file-system changes with the Docker container.
3729

30+
First, set up ``docker-osx-dev`` via shell script.
3831

39-
## For OS X Development
32+
. ./osx_docker_dev_setup.sh
4033

41-
Due to issues using Docker in OSX, development is more efficient if you
42-
install [docker-osx-dev](https://github.com/brikis98/docker-osx-dev).
43-
docker-osx-dev synchronizes host file-system changes with the Docker
44-
container. If you have [``homebrew``](http://brew.sh/) installed, you can
45-
install ``docker-osx-dev`` by typing ``make`` in the root of the Micromasters
46-
project directory. The make file will install or update Docker using Homebrew
47-
and go on to install ``docker-osx-dev``.
48-
49-
Subsequently, before you run the application with ``docker-compose up``,
50-
you would run:
34+
Subsequently, before you run the application with ``docker-compose up``,
35+
you would run this command in a separate terminal tab (assumes machine
36+
name ``mm``):
5137

52-
docker-osx-dev -m default -s ./ --ignore-file '.rsync-ignore'
53-
54-
(Assuming your Docker VM is called ``default``, and your current working
55-
directory is the root of the ``micromasters`` source directory).
38+
docker-osx-dev -m mm -s ./ --ignore-file '.rsync-ignore'
5639

5740
This starts a process that monitors the file system for changes. On startup
5841
you may receive this error:
@@ -68,96 +51,120 @@ you may receive this error:
6851

6952
Answer ``yes``.
7053

71-
## Configuration and Start-up
54+
## Running edX devstack locally _(optional, but recommended)_
55+
56+
Micromasters can work with a live instance of edX, but it's recommended that
57+
you get it running locally. It's obviously more configurable that way, and you'll
58+
likely need to run it locally for other projects in the future.
59+
60+
#### 1) Install edX
61+
Run through the
62+
[instructions provided by edX](https://edx-installing-configuring-and-running.readthedocs.io/en/latest/installation/devstack/install_devstack.html)
63+
up to and including the **LMS Workflow** section. Note that this section mentions
64+
some helpful dummy accounts that edX devstack comes preloaded with (eg: [email protected]).
7265

73-
Create a user who has permission to view the course:
66+
#### 2) Run the machine and SSH into it
7467

75-
docker-compose run web python manage.py createsuperuser
68+
# Start the VM
69+
vagrant up
70+
# Once that's done, ssh into the running VM
71+
vagrant ssh
72+
# Switch to the edxapp account within SSH session
73+
sudo su edxapp
7674

77-
Start the machine:
75+
Switching to the edxapp account sources the edxapp environment and sets the
76+
current working directory to the edx-platform repository. If you get the error
77+
_"Unknown task: devstack, the working directory has not been updated properly"_,
78+
simply run ``cd /edx/app/edxapp/edx-platform`` and re-run the command.
7879

79-
docker-compose up
80+
#### 3) Set up a user with superuser permissions
8081

81-
(OSX only) visit: http://192.168.99.100:8079/
82+
Once in the VM, creating a superuser/setting superuser permissions can be done
83+
in Django admin or in a shell. It's preferable to do it in Django admin as you'll
84+
need to use Django admin for the next step anyway.
8285

83-
Note: Your IP address may vary depending on what address Docker
84-
assigns to your container. If the IP address above doesn't work, enter
85-
this command:
86+
- **In Django admin**
8687

87-
docker-machine ls
88+
Run the server (``paver devstack --fast lms``) and navigate to Django admin
89+
(eg: http://192.168.33.10:8000/admin). In the **Authentication and Authorization**
90+
section, select a **User**, or add one then select it. In the **Permissions**
91+
section, check the **Superuser status** box and save.
8892

89-
The command lists the containers and their URLs. Your container's URL
90-
will be something like ``tcp://192.168.99.100:2376``. Micromasters will
91-
run at that URL, but on port ``8079``. So, for this example, Micromasters
92-
will run at ``192.168.99.100:8079``.
93+
- **In a Python shell**
9394

94-
## Configuring edX devstack
95+
# Kick off an interactive shell
96+
python manage.py lms --settings=devstack shell
9597

96-
These instruction presume that you're running Micromasters in a development
97-
environment that includes a local edX devstack. If you don't have a edX
98-
devstack installed navigate to these
99-
[instructions](https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Devstack)
100-
that walk you through the installation. We'll wait.
98+
### RUN THESE WITHIN THE SHELL ###
99+
from django.contrib.auth.models import User
100+
# We'll update the dummy user 'staff' to have superuser permissions
101+
user = User.objects.get(username='staff')
102+
user.is_superuser=True
103+
user.save()
101104

102-
### Create a superuser
103-
104-
You need a user with superuser privileges to create the edX client for
105-
Micromasters. Start up the edX devstack and ssh into the ``edxapp`` user.
105+
#### 4) Add an OAuth client
106106

107-
vagrant up
108-
vagrant ssh
109-
sudo su edxapp
107+
Run Django admin (see "In Django admin" section from step 2), navigate to the
108+
OAuth2 clients section (eg: http://192.168.33.10:8000/admin/oauth2/client/), and add a
109+
new client. Fill in the values as follows:
110+
111+
- **User**: Use the lookup (magnifying glass) to find your superuser
112+
- **Name**: Anything you want. Something like 'micromasters-local'
113+
- **Url**: The URL where Micromasters will be running. If you're running it via
114+
Docker, run ``docker-machine ip`` from the host machine to get the container IP.
115+
Micromasters runs on port ``8079`` by default, so this value should be something
116+
like ``http://192.168.99.100:8079``
117+
- **Redirect uri**: Your **Url** value with "/complete/edxorg/" at the end
118+
119+
#### 5) Copy relevant values to use in the Micromasters .env file
120+
121+
The Micromasters codebase contains a ``.env.sample`` file which will be used as
122+
a template to create your ``.env`` file. For Micromasters to work, it needs 3 values:
110123

111-
edxapp@precise64:~/edx-platform$ pip install ipython
124+
- ``EDXORG_BASE_URL``
112125

113-
Open an iPython shell and execute these commands:
126+
This value _should_ be ``http://192.168.33.10:8000``. The Vagrant VM IP is hard-coded
127+
in the Vagrantfile, and it's unlikely that edX will change that. The LMS server runs
128+
on port ``8000`` by default.
129+
- ``EDXORG_CLIENT_ID`` and ``EDXORG_CLIENT_SECRET``
114130

115-
edxapp@precise64:~/edx-platform$ python manage.py lms --settings=devstack shell
116-
Python 2.7.10 (default, Jun 29 2015, 22:38:23)
117-
Type "copyright", "credits" or "license" for more information.
131+
These values can be found in Django admin OAuth client section discussed above.
132+
**Client id:** and **Client secret:** values should be auto-generated for
133+
your new client. Use those values for the corresponding ``EDXORG_``
134+
variables in the ``.env`` file
118135

119-
IPython 4.1.2 -- An enhanced Interactive Python.
120-
? -> Introduction and overview of IPython's features.
121-
%quickref -> Quick reference.
122-
help -> Python's own help system.
123-
object? -> Details about 'object', use 'object??' for extra details.
136+
## Docker Container Configuration and Start-up
124137

125-
In [1]: from django.contrib.auth.models import User
138+
First, create a ``.env`` file from the sample in the codebases:
126139

127-
In [2]: User.objects.get(username='staff')
128-
Out[2]: <User: staff>
140+
cp .env.sample .env
129141

130-
In [3]: staff=_
142+
Set the ``EDXORG_BASE_URL``, ``EDXORG_CLIENT_ID``, and ``EDXORG_CLIENT_SECRET``
143+
variables in the ``.env`` file appropriately.
131144

132-
In [4]: staff.is_superuser=True
145+
For first-time container start-up, start it with a full build:
133146

134-
In [5]: staff.save()
147+
docker-compose up --build
135148

136-
In [6]:
137-
Do you really want to exit ([y]/n)? y
149+
In another terminal tab, navigate the the Micromasters directory
150+
and add a superuser in the now-running Docker container:
138151

139-
Start the LMS:
152+
docker-compose run web python3 manage.py createsuperuser
140153

141-
paver devstack lms
154+
Starting the container after this can be done without the ``--build``
155+
param: ``docker-compose up``
142156

143-
Navigate to ``localhost:8000/admin`` and login with the superuser account.
144-
Scroll down to the "Oauth2" section and open "Clients".
145-
Create a new client
146-
name - your choice of name, mine is ``micromasters-local``.
147-
Url - the URL of your local Micromasters instance, a URL on port ``8087``.
148-
Redirect url: the same URL, but with ``/complete/edxorg/`` at the end.
149-
Client type: Chose "Confidential (Web applications)"
157+
You should now be able to do the following:
150158

151-
Make a note of the Client id and the Client secret; you need them to
152-
configure Micromasters. Don't forget to save your new client.
159+
1. Visit Micromasters in your browser on port `8079`. _(OSX Only)_ Docker auto-assigns
160+
the container IP. Run ``docker-machine ip`` to see it. Your Micromasters URL will
161+
be something like this: ``192.168.99.100:8079``.
162+
1. Click "Sign in with edX.org" and sign in by authorizing an edX client. If you're
163+
running edX locally, this will be the client you created in the steps above.
153164

154-
Return to Micromasters and, the project root directory, copy the
155-
``.env.sample`` file to ``.env`` and edit these values:
156-
157-
STATUS_TOKEN: Can be anything. STATUS_TOKEN is not used in local development.
158-
EDXORG_BASE_URL: The URL of your local edX instance. Something like: ``http://192.168.33.10:8000``
159-
EDXORG_CLIENT_ID: The ``Client id`` from the edX Oauth2 client.
160-
EDXORG_CLIENT_SECRET: The ``Client secret`` from the edX Oauth2 client.
165+
As shown above, manage commands can be executed on the Docker-contained
166+
Micromasters app. For example, you can run a shell with the following command:
161167

168+
docker-compose run web python3 manage.py shell
162169

163170

osx_docker_dev_setup.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
curl -o /usr/local/bin/docker-osx-dev https://raw.githubusercontent.com/brikis98/docker-osx-dev/master/src/docker-osx-dev
4+
chmod +x /usr/local/bin/docker-osx-dev
5+
docker-osx-dev install

0 commit comments

Comments
 (0)