Skip to content

Commit

Permalink
adding redeploy playbooks and updating the Installation doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ooemperor committed Mar 21, 2024
1 parent 92cf4e6 commit f52dd2e
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 57 deletions.
34 changes: 34 additions & 0 deletions deployment/ansible/playbooks/redeploy_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CodeGrader - https://github.com/ooemperor/CodeGrader
# Copyright © 2023, 2024 Michael Kaiser <michael.kaiser@emplabs.ch>
#
# This file is part of CodeGrader.
#
# CodeGrader is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# CodeGrader is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with CodeGrader. If not, see <http://www.gnu.org/licenses/>.

# Redeploy CodeGrader Backend as a single Host Installation on Linux Host (Debian)
- name: Setup LXC
import_playbook: lxc_setup.yml

- name: Install CodeGrader Software Backend
import_playbook: codeGrader_install_backend.yml

- name: Setup CodeGrader config files
import_playbook: codeGrader_config_setup.yml

- name: Setup CodeGrader Services
import_playbook: codeGrader_services_setup.yml

- name: Start CodeGrader Backend Services
import_playbook: codeGrader_services_backend.yml

32 changes: 32 additions & 0 deletions deployment/ansible/playbooks/redeploy_frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# CodeGrader - https://github.com/ooemperor/CodeGrader
# Copyright © 2023, 2024 Michael Kaiser <michael.kaiser@emplabs.ch>
#
# This file is part of CodeGrader.
#
# CodeGrader is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# CodeGrader is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with CodeGrader. If not, see <http://www.gnu.org/licenses/>.

# Redeploy CodeGrader Backend as a single Host Installation on Linux Host (Debian)

- name: Install CodeGrader Software Frontend
import_playbook: codeGrader_install_frontend.yml

- name: Setup CodeGrader config files
import_playbook: codeGrader_config_setup.yml

- name: Setup CodeGrader Services
import_playbook: codeGrader_services_setup.yml

- name: Start CodeGrader Frontend Services
import_playbook: codeGrader_services_frontend.yml

34 changes: 34 additions & 0 deletions deployment/ansible/playbooks/redeploy_full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CodeGrader - https://github.com/ooemperor/CodeGrader
# Copyright © 2023, 2024 Michael Kaiser <michael.kaiser@emplabs.ch>
#
# This file is part of CodeGrader.
#
# CodeGrader is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# CodeGrader is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with CodeGrader. If not, see <http://www.gnu.org/licenses/>.

# Redeploy CodeGrader Backend as a single Host Installation on Linux Host (Debian)
- name: Setup LXC
import_playbook: lxc_setup.yml

- name: Install CodeGrader Software
import_playbook: codeGrader_install_full.yml

- name: Setup CodeGrader config files
import_playbook: codeGrader_config_setup.yml

- name: Setup CodeGrader Services
import_playbook: codeGrader_services_setup.yml

- name: Start CodeGrader Services
import_playbook: codeGrader_services_full.yml

129 changes: 72 additions & 57 deletions doc/Installation.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,20 @@
# Installation
This file will document the necessary steps to install and run this project.

## Requirements
This Guide will show the necessary steps for installing and running the project on Debian 11 Servers with Python 3.9.
# General
Within this documentation you will find a Guide on how to manually deploy/install the codeGrader.
In case you prefer a automated way to deploy the codeGrader there are ansible playbooks avaible in the deployment folder.
In a productive deployment you might need to change some variables in the playbooks (e.g. Database Password)

It is assumed that you already have setup such a server and have access with a root user.

## General Steps
```
apt-get install -y python-dev libpq-dev
apt-get install -y pip
```

# Frontend
## Python Packages
```
pip install -r requirements.txt
```
# Backend
Running the backend API after Installtion of the package.
```
cgApiBackend
```
## Python Packages
```
pip install -r requirements.txt
```

## PostgreSQL 15
Installing PostgreSQL Version 15 (according to [PostgreSQL Installation](https://www.postgresql.org/download/linux/debian/))
```
apt update && sudo apt upgrade -y
sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get install postgresql-15
```
By default the only host that can access the database is "localhost". If access to the database shall be established from a different host

Setting up the database (must be done with postgres user):
```
createuser --username=postgres --pwprompt codeGrader
createdb --username=postgres --owner=codeGrader codeGraderDB
psql --username=postgres --dbname=codeGraderDB --command='CREATE ROLE codeGrader'
psql --username=postgres --dbname=codeGraderDB --command='GRANT codegrader TO "codeGrader"'
psql --username=postgres --dbname=codeGraderDB --command='ALTER SCHEMA public OWNER TO codeGrader'
psql --username=postgres --dbname=codeGraderDB --command='GRANT SELECT ON pg_largeobject TO codeGrader'
```
This Guide will show the necessary steps for installing and running the project on Debian 11 or Debian 12 Servers with Python 3.9 or higher.

## Execution Service
For the execution Service we do need some additional packages,so we can create containers and more.
```
apt-get install lxc libvirt0 libpam-cgfs bridge-utils uidmap
```

The installation of the lxc packages can be verified with the <code>lxc-ls</code> command. If the installation was succesful there should not be any output at this point.
If there was some kind of error during the installation, an error message would be shown.

## Evaluation Service
The Evaluation Service does not need any additional packages, than what is already specified in the requirements.txt of the backend package.
It is assumed that you already have setup such a server and have access with a root user.

# Full Installation
Following from here you can find all the needed steps for a full installation on a single host.

Corresponding Ansbile playbook: ```full_setup.yml```

Install all apt packages including postgres:
```
apt-get install -y libpython3-dev libpq-dev lxc libvirt0 libpam-cgfs bridge-utils uidmap pip git
Expand Down Expand Up @@ -160,3 +111,67 @@ systemctl start cgUserFrontend.service
systemctl start cgAdminFrontend.service
```

# Redeployment
If you made any changes in the Code and would like to redeploy the Applications, you can use the corresponding playbooks.

```redeploy_full.yml``` Reinstalls the frontend and backend and restarts it.

```redeploy_backend.yml``` Reinstall only the backend.

```redeploy_frontend.yml``` Reinstall only the frontend.

# Partial Information on specific parts
## General Steps
```
apt-get install -y python-dev libpq-dev
apt-get install -y pip git
```

# Frontend
## Python Packages
```
pip install -r codeGrader/frontend/requirements.txt
```
# Backend
Running the backend API after Installtion of the package.
```
cgApiBackend
```
## Python Packages
```
pip install -r codeGrader/backend/requirements.txt
```

## PostgreSQL 15
Installing PostgreSQL Version 15 (according to [PostgreSQL Installation](https://www.postgresql.org/download/linux/debian/))
```
apt update && sudo apt upgrade -y
sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get install postgresql-15
```
By default the only host that can access the database is "localhost". If access to the database shall be established from a different host

Setting up the database (must be done with postgres user):
```
createuser --username=postgres --pwprompt codeGrader
createdb --username=postgres --owner=codeGrader codeGraderDB
psql --username=postgres --dbname=codeGraderDB --command='CREATE ROLE codeGrader'
psql --username=postgres --dbname=codeGraderDB --command='GRANT codegrader TO "codeGrader"'
psql --username=postgres --dbname=codeGraderDB --command='ALTER SCHEMA public OWNER TO codeGrader'
psql --username=postgres --dbname=codeGraderDB --command='GRANT SELECT ON pg_largeobject TO codeGrader'
```

## Execution Service
For the execution Service we do need some additional packages,so we can create containers and more.
```
apt-get install lxc libvirt0 libpam-cgfs bridge-utils uidmap
```

The installation of the lxc packages can be verified with the ```lxc-ls --fancy``` command. If the installation was succesful there should not be any output at this point.
If there was some kind of error during the installation, an error message would be shown.

## Evaluation Service
The Evaluation Service does not need any additional packages, than what is already specified in the requirements.txt of the backend package.

0 comments on commit f52dd2e

Please sign in to comment.