This is the server backend of the OASIS platform. Please, read REST API reference in docs folder, and general documentation in the wiki.
The server can be run locally with the following steps:
A few preliminary checks (usually only need to do once):
oasis-server-env
, then the steps for creating it and installing the packages would be: python -m venv oasis-server-env
source oasis-server-env/bin/activate
pip install -r requirements.txt
Setup environmental variable pointing to the location where the images shuld be stored. Since we are running locally, including the OASIS webapp, then the image folder should be inside the webapp's public folder and named dev-images
. So if the webapp is installed at ~/oasis-webapp
, then we would do (starting with the unset to make sure that the local server does not try to use an S3 bucket to store images):
unset S3_BUCKET
export IMAGE_UPLOAD_FOLDER=~/oasis-webapp/public/dev-images/
rm -Rf $IMAGE_UPLOAD_FOLDER
Export the environmental variables required by the server.
First group of variables contain the admin credentials, flask app to run, and URL of the webapp:
export ADMIN_EMAIL=admin@youroasis.art
export ADMIN_PASSWORD=your_admin_password
export DATABASE_URL=postgresql://localhost/oasis
export FLASK_APP=run
export WEBAPP_URL=http://localhost:3000/
Second group of variables contain sendmail configuration (the server sends emails to users when there are new notifications, as well as a notification to a predefined inbox when a new user fills out the registration form):
export MAIL_USERNAME=info@youroasis.art
export MAIL_DEFAULT_SENDER=info@youroasis.art
export MAIL_NEW_USER_INBOX=register@youroasis.art
export MAIL_PASSWORD=your_mail_password
export MAIL_SERVER=mail.server.com
export MAIL_PORT=587
Recreate the postgres database:
./clear-db.sh; psql postgres -c "CREATE DATABASE oasis"
Initialize db schema, load tables, updgrade db, creates the admin user (using the values set in the step before):
flask db init; flask db migrate; flask db upgrade; flask seed
If all the previous steps run without errors, you are ready to launch the local server. This can be done in differnt ways.
Using Flask's development server, which does not support WebSocket (OASIS has a built-in chat system that requires WebSocket, so that would not work with this server):
flask run
Using [gunicorn] webserver, which supports WebSocket. There are two possible launch commands, currently only the second one works due to this issue.
gunicorn --bind 127.0.0.1:5000 --worker-class eventlet -w 1 "run:create_app()"
gunicorn --bind 127.0.0.1:5000 -k gevent "run:create_app()"
Server should be ready now, by default at http://127.0.0.1:5000
You can populate the OASIS db with demo data provided in this repo using one of the convenience scripts in the scripts
folder. If you clone the demo-data repo to some location in your computer, for example ~/demo-data
then you could run (from the root of the server folder):
python scripts/populate.py -u http://127.0.0.1:5000 -f ~/demo-data -d
Once the local server is running and the database has been initialized with some data, you can install and run the OASIS webapp locally.
The OASIS server can be installed on Heroku, with an AWS S3 bucket to store images. Once your Heroku and AWS accounts are ready, the deployment of the sever can be performed with the following steps (where we assume the Heroku app is called my-oasis-server
, the S3 bucket is my-oasis-storage
, and we install it on the prod
remote):
Delete previous data and destroy server (optional) to start from scratch:
python scripts/delete_all.py -u https://my-oasis-server.herokuapp.com/ -e <admin email> -p <admin password>
heroku apps:destroy my-oasis-server --confirm=my-oasis-server
Create server:
heroku create my-oasis-server --remote prod
Create database:
heroku addons:create heroku-postgresql:mini --app my-oasis-server
Set S3 bucket:
heroku config:set S3_BUCKET=my-oasis-storage` --remote prod
Set environmental variables:
heroku config:set WEBAPP_URL=https://myoasis.art/ --remote prod
heroku config:set ADMIN_EMAIL=<admin email> ADMIN_PASSWORD=<admin password> --remote prod
heroku config:set AWS_ACCESS_KEY_ID=<access key> AWS_SECRET_ACCESS_KEY=<secret access key> --remote prod
heroku config:set MAIL_USERNAME=<mail username> MAIL_DEFAULT_SENDER=<outbox address> MAIL_NEW_USER_INBOX=<new user inbox> MAIL_PASSWORD=<mail password> MAIL_SERVER=<mail server> MAIL_PORT=<mail port> --remote prod
Push code in server's main branch to Heroku' main branch:
git push staging main:main
If all the previous steps were succesful, then the server db can be initialized with some data:
python scripts/populate.py -u https://my-oasis-server.herokuapp.com/ -f <data folder>