Mr. Pinner's Pinning Lab

This little web app is for uploading and pinning images in IPFS.It uses Blockfrost.io in the backend for all IPFS operations.

This little web app is for uploading and pinning images in IPFS.
It uses Blockfrost.io in the backend for all IPFS operations.

I originally wrote it to keep my Flask skills sharp and to integrate the ipfs_utils.py script from the previous post.  I love the way it turned out.  This is the first time that I've used Bulma instead of Bootstrap and am growing quite fond of it. It is a pretty easy CSS framework to use.  I did have to put some JavaScript in unfortunately, as the burger menu and notification delete required it.  

I will probably not move forward with actually hosting a Mr. Pinner Pinning Lab, but the code is ready for a first crack at it.

Features

+ Flask app Setup for expansion
+ Default site pages controlled with Flask Blueprints [app/home folder etc]
+ Authentication built in with Flask-Login [app/auth folder]
+ IPFS Upload and Pinning [app/lab folder]
+ Database controlled by SQLAlchemy [SQLite by default]
+ Monitored with New Relic

From the README.md in the Repo, how to set up the web app and get it running locally with Docker

Pre-setup

Clone the repo

GitHub - ephergent/mr_pinners_pinning_lab
Contribute to ephergent/mr_pinners_pinning_lab development by creating an account on GitHub.

Containers need a local .env file [see the example below]

source .env

Currently the DB needs to be initialized via the manage.py Python script in app directory.

Create a virtualenv, then source it, then pip install the requirements

cd app
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt

Then run the manage.py script to create the default tables

python manage.py --create_db

This will create pinning_lab.db

You are now ready to cd .. back to the main folder and run the docker-compose command

Now Built with Docker!

Run Docker compose

docker-compose up --build -d

This will build four containers.

docker ps

CONTAINER ID   IMAGE                              COMMAND                  CREATED          STATUS          PORTS                    NAMES
9c54a05016d7   nginx:latest                       "/docker-entrypoint.…"   9 seconds ago    Up 6 seconds    0.0.0.0:80->80/tcp       mr_pinners_pinning_lab_nginx_1
97ac194ad7e0   mr_pinners_pinning_lab_celery      "celery -A pinning_l…"   13 seconds ago   Up 10 seconds   5000/tcp                 mr_pinners_pinning_lab_celery_1
5121745d8b1b   mr_pinners_pinning_lab_flask_app   "gunicorn --bind 0.0…"   13 seconds ago   Up 9 seconds    0.0.0.0:5000->5000/tcp   flask_app
53adb4eda3f3   redis:latest                       "docker-entrypoint.s…"   15 seconds ago   Up 12 seconds   6379/tcp                 redis

Once built and running go to http://localhost to signup and login

EXAMPLE local .env file

export DOCKER_BUILD_NUM='latest'
export FLASK_APP=app.py
export FLASK_DEBUG=1
export FLASK_ENV=development

# Misc ENV vars
export TOKEN_SALT='token'

# Blockfrost API
export BLOCKFROST_IPFS=YOUR_API_KEY

# New Relic
# Change out env based on environment
export NEW_RELIC_ENVIRONMENT='development'
export NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
export NEW_RELIC_LABELS='Application:MrPinnersPinningLab;Geo:World;Team:DEAFMICE;Environment:development'

Docker tear down and destroy

Stop the containers

docker container stop $(docker container list -q)

Prune the left over chaff

docker system prune -a -f