This repository contains all necessary scripts to automatically deploy UNCode with all of its features. Here you'll find a step-by-step guide to deploy it in a CentOS 7 server to be able to host your courses.
For more information, please refer to the project page: https://juezun.github.io
Before you start, we recommend that you review the documentation of proxy settings and the documentation of firewall settings. You can avoid problems related to the configuration of this modules by reading and applying the considerations mentioned there.
These steps will deploy the frontend services and the services to run submissions
-
Have a machine with CentOS 7 and git:
sudo yum install -y git
-
Make sure that there is a password set for root and the user that will execute the scripts
-
Clone the deployment repository
git clone https://github.com/JuezUN/Deployment.git
-
Inside the Deployment folder, make the .sh files runnable:
chmod +x *.sh chmod +x deployment_scripts/*.sh
-
Run the command
./setup_environment.sh && source env.sh
to set the environment variables (such as ports used by the different services). -
Disable selinux
sudo ./deployment_scripts/disable_selinux.sh
Running this command will cause the server to restart automatically so that the changes are applied
-
Install the prerequisites, run
./install_prerequisites.sh
to do this.
Make sure you DON'T run this command with sudo as the user is the one that should be able to use the applications (not sudo)Note: Check the File system docker driver with
docker info
, this should sayoverlay2
. If not, check bellow in common problems to fix this. -
Logout and log back in to the server so that the user can use mongo and docker without
sudo
. -
Modify the
configuration.yaml
file to use the setup you want, this is in the folderconfig
. In the backend option, set it tobackend: tcp://127.0.0.1:2000
, in themultilang
plugin options, set the IP or domain corresponding to this machine. For more information, see the Documentation. -
Modify the config file of
Nginx
inconfig/nginx/conf.d/uncode.conf
with the correct modifications and IP -
Modify the config file of
lighttpd
inconfig/lighttpd/conf.d/fastcgi.conf
setting themax-procs
andmin-procs
that match the number of cores in your server and both values most be equal. -
Execute the script
./run.sh
. -
(Optional) Now you will access to UNCode in the specified domain name or IP. In case you want to download a test course and set it up, run:
./deployment_scripts/add_test_course.sh
.
In previous steps, you have deployed the necessary services to run submissions on UNCode, as well as the frontend. However, if you want to install the linter and python tutor services (tools), here there are two options:
-
If you want to deploy these tools within the same machine, run the command
./tools_host/deploy_tools.sh
to deploy them. There are not any additional settings to be done. -
If you want to deploy the tools in a separate machine from the rest of the application, follow next steps:
-
In
/etc/nginx/conf.d/uncode.conf
file, change the url to proxy the linter, tutor and cokapi services. Instead of proxy pass to localhost, set the domain name or IP of the server where you are deploying these tools. It should look as follows:location /cokapi { proxy_pass http://<IP or damain_name tools machine>/cokapi; } location /linter { proxy_pass http://<IP or damain_name tools machine>/linter; } location /tutor { proxy_pass http://<IP or damain_name tools machine>/tutor; }
-
Modify the
configuration.yaml
file in/var/www/INGInious/
in themultilang
plugin, setting the IP or Domain name of this server, NOT the tools machine. -
Restart the services with
uncode_webapp_restart
. -
Go to tools host deployment documentation to deploy these services in another server.
-
In case you want to add more machines to grade more submissions concurrently, go to Grading host deployment documentation to deploy any number of hosts that will be used as grading machines.
Metabase is a service for data analytics. This is connected to the UNCode's database, that is why you must deploy this service within the same machine.
-
Run the commands:
chmod +x ./metabase/*.sh ./metabase/deploy_metabase.sh
-
Modify the file
/etc/nginx/conf.d/uncode.conf
and add the next proxy ruleslocation /metabase/ { proxy_pass http://localhost:3000/; } location /app/ { proxy_pass http://localhost:3000/; }
-
Restart nginx with
sudo service nginx restart
-
You will access metabase in the path
/metabase
from your browser.
Mongo express is a service deployed with docker to graphically access to the Mongo DB. Deploy this service in the same machine where the DB is stored.
-
Run the next command and set a username and password to Mongo Express as indicated when running the script.
sudo bash $DEPLOYMENT_HOME/deployment_scripts/deploy_mongo_express.sh
-
Modify the file
/etc/nginx/conf.d/uncode.conf
and add the next proxy rule:location /mongo_express/ { proxy_pass http://localhost:8081; }
-
Restart nginx with
sudo service nginx restart
-
You will access Mongo Express in the path
/mongo_express
from your browser.
In order to have a constant monitoring of your different server and services, it is very useful to install a control panel, as well as some services that constantly collect metrics from them. In case you want to install monitoring services, go to the Monitoring documentation.
File deployed in /var/www/INGInious
.
This file specifies which plugins will run when UNCode deploys, set the options you think you need, as well as the corresponding plugins. See the configuration reference.
Every time this file is modified you must restart lighttpd service to load changes.
File located in /etc/lighttpd/conf.d/fastcgi.conf
. This file specifies the configuration related to fastcgi and the processes that lighttpd will create to handle requests.
The options to focus on are max-procs
and min-procs
, these options specify the processes that fastCGI will create. Here we recommend to leave the same value for both options, as this will create an static number of process.
Main configuration file: /etc/nginx/conf.d/uncode.conf
. This file specifies the reverse proxy rules that are processed by nginx,
Modify the server_name and the IP, as well as other settings you think should be configured.
Modify the $DEPLOYMENT_HOME/docker-compose.yml
file, which deploys these services, as you want. You can set different memory limits according to your necessities.
These are some helpful scripts or commands that will help on managing the server. If you want to know more about them please go to uncode_scripts and read the documentation inside it. You will learn how to restart the services, make automatic backups, among others.
When server reboots, you will see that the frontend will work fine but if you try to submit code it won't work. To fix this, follow next few steps:
- Run the command
$DEPLOYMENT_HOME/setup_environment.sh && source env.sh
to set the environment variables (such as proxy and ports used by the backend services). - Run the command
sudo bash $DEPLOYMENT_HOME/deployment_scripts/build_all_containers.sh
- Run the command
uncode_webapp_restart
in order to restart all services and load changes.
You are all set, try submitting code and test the different services.
There are some problems that you might find when deploying the services.
- Check the firewall rules. See the documentation we have wrote about this to allow some ports.
- Docker compose says that the ports of the micro services are not specified. Solution: Make sure you run the command
source env.sh
- Docker file system driver should be
overlay2
, to check the config of docker, rundocker info
and theStorage docker
should say overlay2. In case it is not the case, check the docker documentation to change the File system docker driver. - Mongo DB fails to start after a reboot. There is an unsolved issue with systemd and mongod service that prevents it from starting correctly at boot. Until this issue is solved, the following workaround will start mongodb as INGInious needs.
sudo mongod -f /etc/mongod.conf
- If you copy files into the tasks folder, the owner of new files may be different of ligttpd so you must change the owner of these files. For that, run the next command recursively on all the files inside tasks folder:
sudo chown -R lighttpd:lighttpd /var/www/INGInious/tasks/*
.
Go to CONTRIBUTING to see the guidelines and how to start contributing to UNCode.
Distributed under the AGPL-3.0 License. See LICENSE for more information.
In case of technical questions, please use the gitter communication channel.
In case you want to host your course on our deployment, email us on: [email protected]
UNCode: https://uncode.unal.edu.co
Project page: https://juezun.github.io/