3wordchant
72c04d8495
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> |
||
---|---|---|
capsulflask | ||
docs | ||
.drone.yml | ||
.gitignore | ||
app.py | ||
docker-compose.yml | ||
Dockerfile | ||
letsencrypt-root-ca.crt | ||
LICENSE.md | ||
Pipfile | ||
Pipfile.lock | ||
README.md | ||
setup.cfg | ||
setup.py |
capsul-flask
Python Flask web application implementing user accounts, payment, and virtual machine management for a smol "virtual machine (vm) as a service" aka "cloud compute" provider. Originally developed by Cyberia Computer Club for https://capsul.org
capsul-flask
integrates with Stripe as a credit card processor, and BTCPay Server as a cryptocurrency payment processor.
capsul-flask
invokes shell-scripts to create/manage libvirt/qemu vms, and it depends on dnsmasq
to act as the DHCP server for the vms.
capsul-flask
has a "hub and spoke" architecture. The "Hub" runs the web application and talks to the Postrges database, while the "Spoke"(s) are responsible for creating/managing virtual machines. In this way, capsul can be scaled to span more than one machine. One instance of the capsul-flask application can run in both hub mode and spoke mode at the same time, however there must only be one instance of the app running in "Hub" mode at any given time.
Quickstart (run capsul-flask on your computer in development mode)
# get an instance of postgres running locally on port 5432
# (you don't have to use docker, but we thought this might be the easiest for a how-to example)
docker run --rm -it -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres &
# install dependencies
sudo apt install pipenv python3-dev libpq-dev
# download and run
git clone https://giit.cyberia.club/~forest/capsul-flask
cd capsul-flask
pipenv install
pipenv run flask run
Interested in learning more? How about a trip to the the docs/
folder: