1
1
# Micromasters
2
2
Portal for learners and course teams to access MITx Micromasters programs
3
3
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 )
5
10
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
10
12
11
- pip install docker-compose
12
- docker-compose up
13
+ #### Create your docker container:
13
14
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
22
16
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.
31
18
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)"
33
23
34
- or to create root user :
24
+ #### Enable file syncing between the host machine and Docker :
35
25
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.
37
29
30
+ First, set up `` docker-osx-dev `` via shell script.
38
31
39
- ## For OS X Development
32
+ . ./osx_docker_dev_setup.sh
40
33
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 `` ):
51
37
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'
56
39
57
40
This starts a process that monitors the file system for changes. On startup
58
41
you may receive this error:
@@ -68,96 +51,120 @@ you may receive this error:
68
51
69
52
Answer `` yes `` .
70
53
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] ).
72
65
73
- Create a user who has permission to view the course:
66
+ #### 2) Run the machine and SSH into it
74
67
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
76
74
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.
78
79
79
- docker-compose up
80
+ #### 3) Set up a user with superuser permissions
80
81
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.
82
85
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**
86
87
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.
88
92
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**
93
94
94
- ## Configuring edX devstack
95
+ # Kick off an interactive shell
96
+ python manage.py lms --settings=devstack shell
95
97
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()
101
104
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
106
106
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:
110
123
111
- edxapp@precise64:~/edx-platform$ pip install ipython
124
+ - `` EDXORG_BASE_URL ``
112
125
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 ``
114
130
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
118
135
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
124
137
125
- In [1]: from django.contrib.auth.models import User
138
+ First, create a `` .env `` file from the sample in the codebases:
126
139
127
- In [2]: User.objects.get(username='staff')
128
- Out[2]: <User: staff>
140
+ cp .env.sample .env
129
141
130
- In [3]: staff=_
142
+ Set the `` EDXORG_BASE_URL `` , `` EDXORG_CLIENT_ID `` , and `` EDXORG_CLIENT_SECRET ``
143
+ variables in the `` .env `` file appropriately.
131
144
132
- In [4]: staff.is_superuser=True
145
+ For first-time container start-up, start it with a full build:
133
146
134
- In [5]: staff.save()
147
+ docker-compose up --build
135
148
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:
138
151
139
- Start the LMS:
152
+ docker-compose run web python3 manage.py createsuperuser
140
153
141
- paver devstack lms
154
+ Starting the container after this can be done without the `` --build ``
155
+ param: `` docker-compose up ``
142
156
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:
150
158
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.
153
164
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:
161
167
168
+ docker-compose run web python3 manage.py shell
162
169
163
170
0 commit comments