A server shell for you to play with
Powered by Django + Nginx + Postgres + Bootstrap + Celery.
- Install Docker Community Edition
- Install docker-compose into python3, e.g.
pip3 install --user docker-compose
- Add your user to the docker group.
sudo usermod -a -G docker username;
you may have to reboot after this step for you to show up in the group.
- Create a file
.local_paramsin the root directory using
.local_params_examplesas a template.
Read section “Running jobs” for the details.
You should then use the
local-docker-compose script as a drop in replacement
for docker-compose. For example, to start the server you can
local-docker-compose up --build.
Cleaning up after docker for a clean rebuild:
./cluspro-docker-compose rmwill remove the containers
docker volume prune
If you don’t explicitly remove the volumes between docker runs, the databases persist,
so you can stop the containers and launch them again safely without any loss of data.
Docker runs several services: web (which runs Gunicorn), nginx, db (Postgres database).
Gunicorn handles the python (Django) code, accesses the database and cooperates with Nginx.
Celery is a background task manager and it need rabbitMQ to run (message broker). Flower is
a task monitor, which is powered by Celery. It can be accessed at localhost:5555
All the frontend code is located in
The structure of
server/ directory is enforced by the Django rules, so we have
server/server, where all the server settings are located (
settings.py) as well as
config.py is where the custom variables are kept (e.g. email login
and password for sending messages to the user), which in turn are populated from
the environment, which is set in docker-compose.yml.
core/ contains the app code, as it’s called in Django.
core/templates has all
the html files,
core/static – CSS and JS, and
runner/ contains the code for job
views.pyis the main file – it has functions, which render the pages and handle
all the forms and requests. Most of functions return an HTML response.
urls.pyassigns URLs to the functions in
models.pycontains custom data tables, which are added to the default Django
tables. Right now it contains a model for jobs, which can be customized as you wish.
The intention, however, was to keep all the generic job fields as separate class attributes
(job name, IP etc.) and to store all the rest job specific parameters as a json string
in details_json field. This way we can prevent creating many different tables for different
job types or addition of infinite new fields to the same job table (once we add new job parameters,
All the forms on the website are contained in
forms.pyand it should
be kept so. These forms are all handled in
emails.pyhas messages for users, whenever we want to send them something. They
use the e-mail address and password specified in
server/settings.py, which are in
turn taken from environmental variables in
docker-compose.yml. If they were not
specified you will get an error, whenever the server is trying to send a message.
env.pyis where you should keep your local variables. Also all the variables
envdictionary will be passed as a context to the html templates, so you
can refer to them in the templates.
At the first launch
Two users are created.
- admin with password ‘admin’. This is a superuser, you should change the
password for it immediately. The admin page is located at http://localhost:8080/admin
- anon, which is where you log in once you click ‘use without your own account’
button on the login page. It has limited permissions.
storage/ directory is created in the root, where all the jobs will be kept.
When you run jobs they are stored in docker container in
/storage, which is
by default mounted in your project root. You can change this in
Storage has two directories:
tmp/ for temporary storage, if you need to compute
or check something before adding the job to the database, and
jobs/ with all
Currently a job performs addition of two integer numbers. Some additional requirements are added to
demonstrate how to use error pop-ups etc. The task itself is located in
Environmental variables with some paths, e-mail login and password are stored
.local_params, which are used when you run
local-docker-compose. To create the
.local_params_example as a template.
Variables for sending e-mails. If you don’t specify them, everything will still run, but you will
get errors when new users register etc.
If your e-mail is
[email protected] and the password is
password then the values should be:
EMAIL_USER – server
EMAIL_PASS – password
EMAIL_HOST – smtp.gmail.com
RABBITMQ_PASS will be generated and added to
.local_params at the first run of
specified by the user.
LOCAL_PORT is the port, through which you access the server (default is
SECRET_KEY is for Django internal use (is generated at the first run
local-docker-compose) and should be kept secret.