forked from 3wordchant/capsul-flask
0fa7fb28b5
* forest's ReadMe docs changes * add Configuration-type-stuff that lives in the database
69 lines
1.7 KiB
Markdown
69 lines
1.7 KiB
Markdown
# How to run Capsul locally
|
|
|
|
## <a name="manually"></a>Manually
|
|
|
|
Ensure you have the pre-requisites for the psycopg2 Postgres database adapter package:
|
|
|
|
```sh
|
|
sudo apt install python3-dev libpq-dev
|
|
pg_config --version
|
|
```
|
|
|
|
Ensure you have the wonderful `pipenv` python package management and virtual environment cli:
|
|
|
|
```sh
|
|
sudo apt install pipenv
|
|
```
|
|
|
|
Create python virtual environment and install packages:
|
|
|
|
```sh
|
|
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`):
|
|
|
|
```sh
|
|
docker run --rm -it -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres
|
|
```
|
|
|
|
Run the app
|
|
|
|
```sh
|
|
pipenv run flask run
|
|
```
|
|
|
|
or, using Gunicorn:
|
|
|
|
```sh
|
|
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.
|
|
|
|
```sh
|
|
pipenv run flask cli sql -c "INSERT INTO payments (email, dollars) VALUES ('<your email address here>', 20.00)"
|
|
```
|
|
|
|
## Running scheduled tasks:
|
|
|
|
```sh
|
|
pipenv run flask cli cron-task
|
|
```
|
|
|
|
## <a name="docker_compose"></a>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:
|
|
|
|
```sh
|
|
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](./configuration.md).
|