Skip to content
Snippets Groups Projects

Local Development Setup

The following instructions guide you through the installation and configuration of a local environment to develop and experiment with the Moodle autograde infrastructure.

Installation

Step 0: Required tools

The following tools are required for local experimentations:

  • docker, the Docker containers runtime
  • minikube, to create a local Kubernetes cluster
  • kubectl, the CLI for interacting with Kubernetes cluster
  • make, the build automation tool
  • git, the distributed version control system

You will first have to clone the project repository with its dependencies

git clone --recursive git@gitlab.epfl.ch:cs107/moodle-autograde.git

Step 1: Start minikube

Before starting the minikube cluster, you will have to make sure that the Docker Engine is running. If not, please start the Docker deamon before running the following command:

make start-minikube 

Step 2: Build the images

Before deploying the service to your local cluster, you will have to build the Docker images from your local repository. Bare in mind that any changes in the code will require building new images.

make build-moodle

Build the autograde image:

make build-autograde

Build the autograde submission manager:

make build-submission-manager

Step 3: Deployment

Now that you have built the project, the next step will be to deploy it to your local minikube cluster. You can run the following Makefile target deploy to successfully deploy the services:

make deploy

Note that it can take a few minutes after running the command for the services to be fully deployed.

Step 4: Configuring your local domain names

Link the local instance of Moodle with the host moodle. This is done by adding the line 127.0.0.1 moodle to /etc/host:

make add-host

Step 5: Start the tunnel

As minikube resides in a Docker container, the cluster's network is isolated from the host network. To access the cluster's services (moodle, autograde, ...), you will need to start a network tunnel between the minikube cluster and your computer. You can create the tunnel by running the following command in a new terminal:

make start-tunnel

This commands runs until exited.

Step 6: Access the services

The local instance of Moodle is accessible at http://moodle.

The autograde service is reachable at http://localhost:8082/api/v1/ping.

Step 7: Moodle installation

At this point you should see the following webpage when accessing http://moodle:

moodle installation

Go through the installation step. You can enter whatever value you want for the required fields.

Step 8: Moodle configuration

Now that Moodle is installed, follow the instruction in moodle_config.md to configure the Moodle instance.

Step 9: Env configuration

In the file local/secrets/autograde-service-secrets.env set the AUTOGRADE_MOODLE_TOKEN to the Moodle token generated in the previous step. The token can be found in Moodle at Site Administration > Server > Manage Tokens.

Reload the autograde service:

make deploy restart-autograde

At this point you should have a local instance of the Moodle autograde cluster configured and running.

Step 10: To go further

Now that a local instance of the autograde cluster is setup you can experiment with creating classes and autograding homeworks.

Stop / Destroy the cluster

Stop the cluster:

make stop-minikube

With the stop command, the state of the cluster is saved, and the cluster can be resumed with:

make start-minikube 

Destructive stop, the cluster is stopped and removed:

make destroy-minikube

Cluster dashboard

Get insight about the internals of the cluster:

make dashboard 

Reset the local host configuration

You can remove the mapping from the moodle host name with:

make rm-host

Kubectl context

Kubectl is the command line tool to interact with a Kubernetes cluster. The command that starts the minikube also configures kubectl to interact with the local cluster. If you work with another Kubernetes cluster and want to switch back the kubectl context to the local autograde cluster, use the following command:

make set-context 

Development

During development, if modifying the plugin code or the autograde service you must rebuild the corresponding image and redeploy the cluster to apply the changes.

After a change to the autograde service:

make build-autograde
make deploy restart-autograde

After a change to the Moodle plugin:

make build-moodle
make deploy restart-moodle