Skip to content

The-Lammert-Lab/TinnitusExpWebApp.jl

Repository files navigation

TinnitusExpBackEnd.jl

Codebase for website to run the tinnitus experimental protocol built using Genie Framework.

Contains functionality for subject and admin users, careful organization and storage of data, dynamically generated pages, creation of unique protocols, assignment of protocols to subjects, and more.

To set up and host the website locally, follow these steps in the Julia REPL:

using Pkg
Pkg.activate(".")
Pkg.instantiate()
using Genie
Genie.loadapp()

The following must be set in your environment. I recommend putting a .env in the base of this directory.

POSTGRES_PASSWORD= POSTGRES_DB=postgres POSTGRES_USER=postgres GENIE_SECRET_TOKEN=<random string, suggested 64 chars>

You will need a postgres db for the server to start. To run just postgres and pgadmin in docker "docker compose -f local_compose.yaml up" If you are using a .env file, run "source load_env.sh", you can look at it but it's just a minor time saver combining 3 command into one.

Finally, to locally host the website, simply run up().

Work in progress as of June 2024.

Run with docker

create .env file here

POSTGRES_PASSWORD=<password>
POSTGRES_DB=postgres
POSTGRES_USER=postgres
GENIE_SECRET_TOKEN= <random base64 string> #Get from Genie.Secrets.secret()
PGADMIN_DEFAULT_EMAIL=bbclab@holycross.edu
PGADMIN_DEFAULT_PASSWORD=<password>

after ensuring docker is installed

docker compose up --build

It will have the container built and started at localhost:8000, a postgres database (not accessible outside of the docker network generated by the compose file), and pgadmin at localhost:8001 which can be used to collect the data generated from the experiments.

Note: while the database scheme is generated on first start, not default admin user is created (yet). For now you can access the user table in pgadmin and create a row for that user. Give it a name, the password can be anything hashed with sha256 (future work could be making this webapp use a better password hash...) and check is_admin. More users can be created from the admin page of the webapp once this user exists.

For development:

docker compose -f local_compose.yaml up

this docker file will mount the local files so that any changes will affect the running sever

Post image to Docker Hub

Let's make a cross platform builder with buildx

docker buildx create --platform linux/amd64,linux/arm64 --name tinnitus_builder --driver docker-container --use

We only deploy to amd64 ATM but arm servers may be worth exploring in the future.

User the builder and push to Docker Hub. make sure you run docker login first.

docker buildx build --platform linux/amd64,linux/arm64 --push -t bbclab/tinnitusexpwebapp -t bbclab/tinnitusexpwebapp:0.0.1 .

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors