To start up the HTWK MOOC platform there are a few steps to follow, which will be layed out in the following sections. As container orchestration we need Nomad first, as it has to be installed on the host system. Once this precondition is met, we can start with the deployment using Docker compose. 

**For a quick installation, all necessary instructions are printed in bold. The text gives a detailed explanation of the steps.**

=== Installation of Nomad ===
**To install Nomad there should be a guide on the HashiCorp website: link:https://developer.hashicorp.com/nomad/docs/install[Nomad Installation Instructions]**.
After a successful installation (for example using a package repository), Nomad needs to be running on localhost using port 4646. Additionally, when enabled as systemd service it should be started automatically on system boot. Both should be set up by default.

To check if Nomad is running correctly, the following command can be used and should return the hostname of the instance:

```
curl localhost:4646/v1/status/leader
```

Later on, this could be scaled to a cluster of multiple instances to keep the platform running on a larger scale.

The CodeOcean local setup guide advices to turn on Memory Oversubscription for Nomad now and with every subsequent restart of nomad with the following command:

```
curl -X POST -d '{"SchedulerAlgorithm": "spread", "MemoryOversubscriptionEnabled": true}' http://localhost:4646/v1/operator/scheduler/configuration 
```

This command is automatically executed when the Docker containers are started, so it is not necessary if the platform is started with Docker Compose.

=== Pulling the CodeContender repository ===
The repository for the HTWK MOOC platform is hosted on the GitLab instance of the faculty DIT. It consists of submodules for Poseidon and Codeocean, which have to be initialized after cloning the repository.

**The repository can be cloned with the following commands:**
```
git clone https://gitlab.dit.htwk-leipzig.de/htwkmooc/codecontender.git
cd codecontender
git checkout submodules
git submodule update --init
```

Because the HPI repositories contain additional submodules, that are for internal use only and not necessary for the HTWK platform, the init command does not need to be recursive.

=== Deployment with Docker Compose ===

To build and start the platform, Docker Compose is used. Default username and password for the admin can be changed in the `codeocean/docker-compose.yml` file. The default values are `support@htwkalender.de` and `htwkalender`.
 **The following command downloads the necessary images, builds the containers and starts them:**

```
docker-compose up --build
```

All data used by CodeOcean is stored in a Postgres database which is mounted 

.This doesn't work yet, we have to manually go into the `poseidon` folder and copy `configuration.example.yaml` to `configuration.yaml` and adjust the following:
- `server.address` to `0.0.0.0`
- `nomad.address` to `host.docker.internal`

The rest seems to be left unchanged...

==== Checking access to CodeOcean ====

After starting up the Docker containers, the platform should be running on port 443 of the host system. This can be checked by navigating to https://localhost in a web browser on the host machine. 

=== Installing openEdx ===

The openEdx platform itself is not containerized, but there is a containerized distribution called Tutor, which can be deployed to a Kubernetes. Following the short installation process for a local deployment. Kubernetes instructions are following in the next section.

```
pip install tutor[full]
tutor local launch
```

After inputting the necessary information, all services should be running and the platform should be accessible on localhost. This can be checked by navigating to http://[studio.]local.edly.io on the host. This only works, when the port mapping for the CodeOcean container is changed. The domain points to localhost and is interpreted by a reverse proxy. Problem is, that logging to CodeOcean doesn't work at a different port, as 443 is hardcoded in the frontend.
