Commit Graph

49 Commits

Author SHA1 Message Date
6a587ac7fc trying to do CaptureLogOutputDuringTestsFilter (but no worky yet) 2021-08-16 02:07:36 +02:00
3wc
2b33573890 Fix capsul create tests, post-test cleanup, tidy merge 2021-08-16 02:07:36 +02:00
da4d28f70c ensure that app is defined in app.py to fix login link logging issues.
also shuffled some things around for cleanliness
2021-08-16 02:07:36 +02:00
3wc
6bd02a660e Basic testing using flask-testing
This commit makes it possible to override settings during tests, by
switching capsulflask/__init__.py to a "create_app" pattern, and using
`dotenv_values` instead of `load_dotenv`.

The create_app() method returns a Flask app instance, to give
more control over when to initialise the app. This allows setting
environment variables in test files.

Then, use dotenv_values to override loaded .env variables with ones from
the environment, so that tests can set `POSTGRES_CONNECTION_PARAMETERS`
and `SPOKE_MODEL` (possibly others in future..).

Inital tests for the "landing" pages, and login / activation, are
included.
2021-08-16 02:07:34 +02:00
d4a9f2f40a Make the displayed SSH username configurable
Some checks failed
continuous-integration/drone/pr Build is failing
This patch allows the SSH username displayed in templates to be
configured through the SSH_USERNAME environment variable.
2021-08-10 00:30:45 +00:00
72c04d8495 Docker image, & local development docker-compose.yml (#2)
All checks were successful
continuous-integration/drone/push Build is passing
Adds:
- a Docker image, which can be used in both development and production
- a `docker-compose.yml` file for local development (could probably be adapted for production deployments)

Testing:
- `git checkout docker`
- `docker-compose up`
- pray 🙏
- go to http://localhost:5000

## App architecture

I added the ability to load secret config variables (`HUB_TOKEN`, `STRIPE_SECRET_KEY` etc) from files, to support [Docker Secrets](https://docs.docker.com/engine/swarm/secrets/) natively. The code should probably log an error if a specified `HUB_TOKEN_FILE` doesn't exist instead of failing silently..

## Docker architecture

This uses a multi-stage build to reduce the size of the final image -- having pipenv install to a predefined virtualenv, and then copying that over.

The compose file doesn't include a definition for a cron runner service, and I haven't tested running one yet. Here be dragons!

You can rebuild the image locally using `docker-compose build`, but this isn't required for changes to the app code, only if you edit the `Dockerfile`, or want to publish your image for use on a swarm server (in which case you will need to edit the image name to put in your own Docker hub credentials).

Currently, the image is rebuilt (should set up auto-tagging..) and published with every push to this 3wordchant/capsul-flask fork.

Reviewed-on: #2
Co-authored-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
Co-committed-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
2021-07-22 01:18:10 +02:00
5bb76173dd Add custom themes, THEME setting, basic "yolocolo" theme (#7)
Specify `THEME=yourtheme`, add some HTML files in `capsulflask/theme/yourtheme` 👌

We probably want to reduce copypasta in the current `yolocolo` theme by using template inheritance, at some point.

Reviewed-on: #7
Co-authored-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
Co-committed-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
2021-07-22 01:15:39 +02:00
3wc
8f2becb9ee Fix SyntaxWarning on is not ""
`capsulflask/__init__.py:143: SyntaxWarning: "is not" with a literal. Did you mean "!="?`
2021-07-21 21:51:50 +02:00
36329796f0 define BTCPAY_ENABLED based on URL and btcpay key, pass it explicitly 2021-07-21 12:12:41 -05:00
3wc
357d99cb91 Add load_config_vars context processor..
..to allow accessing config variables in the templates.

This removes the need for adding config variables manually to template
contexts.
2021-07-21 00:19:38 +02:00
a2f2e744e4 MAIL_USE_TLS=False, MAIL_USE_SSL=True defaults 2021-07-11 10:28:47 -05:00
47cdb0c7e6 hotfix support MAIL_USE_SSL 2021-07-09 14:44:48 -05:00
862b14545b more managed ips work: cli sql improvements, added admin panel 2021-07-09 14:13:28 -05:00
a42d35be51 more fixing default values for quick start 2021-07-07 15:17:00 -05:00
bdabd61057 fix defaults for running locally and make email server not required. 2021-07-07 13:47:21 -05:00
3cb6992359 don't crash if btcpay key is invalid: log warning msg 2021-06-27 10:46:48 -05:00
ebf338eb12 don't crash if btcpay key is invalid 2021-06-27 10:41:46 -05:00
j3s
e6cba96d2d Correct default email settings 2021-06-27 10:40:34 -05:00
dbff6e23ed simplify postgres connection parameters as a single string 2021-02-16 16:08:54 -06:00
2bc5b10284 add INTERNAL_HTTP_TIMEOUT_SECONDS option 5min default 2021-02-15 21:00:34 -06:00
dad6547825 Merge branch 'master' into multiple-hosts
Conflicts:
	capsulflask/console.py
	capsulflask/db.py
	capsulflask/shared.py
	capsulflask/virt_model.py
2021-02-15 17:52:17 -06:00
3f6491f359 add support for postgres sslmode 2021-01-20 16:43:32 -06:00
e9d6230c69 remove janky logger monkey patch 2021-01-04 17:20:30 -06:00
d82aa99c40 working on cleaning up the logs 2021-01-04 17:20:03 -06:00
4833c6250b create capsul is working 2021-01-04 15:02:56 -06:00
6764c5c97d got httpclient working, spoke heartbeat is working 2021-01-04 13:32:52 -06:00
42a8e0c886 http client class 2021-01-03 15:19:29 -06:00
c59dc21ba6 starting work on hub mode and spoke mode -- implemented hub model 2021-01-02 17:10:01 -06:00
d8d6124005 forest uncommitted changes on multi-host branch 2020-12-29 17:34:43 -06:00
672ff49d6d implement content-security-policy, static assets cache bust, and fix
stripe back button ratchet issue

because the only way to use stripe checkout is to run their proprietary
JS, and we arent using a SPA, naturally what happens is, when you land
on the stripe payment page if you hit the back button it goes back to
the same page where you got re-directed to stripe. this commit fixes
that.
2020-05-22 15:20:26 -05:00
e2c51d067e implement ensure_vms_and_db_are_synced in cron task and add default
sender to readme
2020-05-21 21:40:41 -05:00
7a478b7ab1 read config properly 2020-05-19 22:55:08 -05:00
5b5c752e1a make VIRTUALIZATION_MODEL configurable 2020-05-19 22:46:11 -05:00
26340f118f trying to fix logging 2020-05-15 23:19:01 -05:00
3bd9d24a97 support dotenv impls that break on multiline strings 2020-05-15 18:49:17 -05:00
e9dcf80f6c btcpay working! added bitpay client code to source tree to fix a bug
fixed a stripe race condition

added account balance warning to account balance page
2020-05-15 18:18:19 -05:00
0dc58ed6a8 add sql cli and explain it in the readme 2020-05-14 20:05:02 -05:00
8de802aff5 btcpay generating invoices and payments can be invalidated 2020-05-14 18:03:00 -05:00
58f85edcb4 added btcpay pairing instructions to readme 2020-05-14 12:40:25 -05:00
30464ac8e5 metrics are working!!! 2020-05-13 00:28:53 -05:00
d2165e49a5 fix name collision 2020-05-12 12:40:10 -05:00
08e23cf0d1 stripe payment processor 2020-05-12 12:38:36 -05:00
d293d43392 starting to work on stripe 2020-05-12 01:42:50 -05:00
231d1ed7c0 create capsul and capsuls list page working 2020-05-11 15:13:20 -05:00
18e6a1b141 starting to build console controller and views 2020-05-11 01:47:14 -05:00
7932db90d5 added FAQ, Changelog, and Support static pages 2020-05-10 22:55:16 -05:00
d706ae7761 updating virt_model with email and 2020-05-10 20:23:00 -05:00
64bca1fd97 it sends a magic link when you log in 2020-05-09 22:59:22 -05:00
4a1924587c postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00