capsul-flask/docs/local-set-up.md

1.7 KiB

How to run Capsul locally

Manually

Ensure you have the pre-requisites for the psycopg2 Postgres database adapter package:

sudo apt install python3-dev libpq-dev
pg_config --version

Ensure you have the wonderful pipenv python package management and virtual environment cli:

sudo apt install pipenv

Create python virtual environment and install packages:

pipenv install

Run an instance of Postgres (I used docker for this, you can use whatever you want, point is its listening on localhost:5432):

docker run --rm -it -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres

Run the app

pipenv run flask run

or, using Gunicorn:

pipenv run gunicorn --bind 127.0.0.1:5000 -k gevent --worker-connections 1000 app:app

Note that by default when running locally, the SPOKE_MODEL is set to mock, meaning that it won't actually try to spawn vms.

Crediting your account

Once you log in for the first time, you will want to give yourself some free capsulbux so you can create fake capsuls for testing.

pipenv run flask cli sql -c "INSERT INTO payments (email, dollars) VALUES ('<your email address here>', 20.00)"

Running scheduled tasks:

pipenv run flask cli cron-task

Run locally with docker-compose

If you have Docker and Docker-Compose installed, you can use the 3wordchant/capsul-flask Docker image to launch capsul-flask, and a Postgres database server, for you:

docker-compose up

capsul-flask will read settings from your .env file as usual; you can set any of the options mentioned in the configuration documentation.