Host Optinist yourself for multiuser use
Setup multiuser mode
Follow the steps below to setup multiuser
mode.
Clone the repository
In your hosting server, clone the OptiNiSt repository.
git clone git@github.com:oist/optinist.git -b main
copy config files
cp studio/config/.env.example studio/config.env cp studio/config/auth/firebase_config.example.json studio/config/auth/firebase_config.json
Create your Firebase Project
Click “Add project”.
Enter your project name, and click “Continue”.
Google Analytics is optional. You can choose “Enable Google Analytics for this project” or not.
After your project is ready, click “Continue”.
Setup Firebase Authentication
Select “Build > Authentication” from the left menu.
Select “Get started”.
Select “Sign-in method” tab.
Select “Add new provider” in “Sign-in providers” section.
Click “Email/Password” and enable it.
Click “Save”.
Create admin user for the project
Select “Authentication” from the left menu.
Select “Users” tab.
Click “Add user” button.
Fill the form and click “Add user”.
Email address: your email address
Password: your password
Created user’s “User UID” is required later.
Get Firebase tokens
Click setting icon(besides Project Overview), then select “Project settings” from the left menu.
Select “General” tab.
Select “web app” in “Your apps” section.
Enter your app name, and click “Register app”.
“Also set up Firebase Hosting for this app” is not required.
Click continue to console.
Set the following values to
studio/config/auth/firebase_config.json
.apiKey
authDomain
projectId
storageBucket
messagingSenderId
appId
(keep databaseURL blank)
Select “Service accounts” tab.
Click “Generate new private key” in “Firebase Admin SDK” section.
Put the downloaded file to
studio/config/auth/firebase_private.json
.
Setup mysql(or mariadb)
Install mysql(or mariadb) server.
Connect mysql server.
mysql -u root -p
Create database for your project.
CREATE DATABASE YOUR_DATABASE_NAME;
Create user for your project.
CREATE USER 'DB_USER_NAME'@'localhost' IDENTIFIED BY 'DB_USER_PASSWORD';
Grant all privileges to the user for the database.
GRANT ALL PRIVILEGES ON YOUR_DATABASE_NAME.* TO 'DB_USER_NAME'@'localhost';
Set OptiNiSt config
Edit
studio/config/.env
Change
SECRET_KEY
to any random string.Change
USE_FIREBASE_TOKEN
toTrue
.Change
IS_STANDALONE
toFalse
Set
MYSQL_SERVER
to your hostSet
MYSQL_DATABASE
to {YOUR_DATABASE_NAME}, which you created in the previous step.Set
MYSQL_USER
to {DB_USER_NAME}, which you created in the previous step.Set
MYSQL_PASSWORD
to {DB_USER_PASSWORD}, which you created in the previous step.MYSQL_ROOT_PASSWORD
can be left commented.
Setup Frontend
Install node.js(version 20)
https://nodejs.org
Install yarn
npm install -g yarn
Install frontend requirements
cd frontend yarn install
Build frontend
yarn build
Setup Backend
See OptiNiSt installation guide.
After create and activate conda environment for the project, run following commands
Install backend requirements
cd studio pip install .
Setup database
alembic upgrade head
Insert initial data
mysql -u DB_USER_NAME -p
USE YOUR_DATABASE_NAME; INSERT INTO organization (name) VALUES ('YOUR_ORGANIZATION_NAME'); INSERT INTO roles (id, role) VALUES (1, 'admin'), (20, 'operator'); INSERT INTO users (uid, organization_id, name, email, active, ) VALUES ('USER_UID', 1, 'YOUR_EMAIL', 'YOUR_PASSWORD', 1); INSERT INTO user_roles (user_id, role_id) VALUES (1, 1);
USER_UID is the user uid you created in the previous step (Create admin user for the project).
Only 2 roles, “admin” and “operator” are supported for now.
“admin”
can manage other users
“operator”
general user
Run OptiNiSt
python main.py
Access to
http://{YOUR_HOST}:8000
from your browser.