Docker image, & local development docker-compose.yml (#2)
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: https://git.autonomic.zone/3wordchant/capsul-flask/pulls/2
Co-authored-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
Co-committed-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
2021-07-21 23:18:10 +00:00
|
|
|
---
|
|
|
|
version: "3.8"
|
|
|
|
|
|
|
|
services:
|
|
|
|
app:
|
|
|
|
image: 3wordchant/capsul-flask:latest
|
|
|
|
build: .
|
|
|
|
volumes:
|
|
|
|
- "./:/app/code"
|
|
|
|
- "../tank:/tank"
|
|
|
|
# - "/var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock"
|
|
|
|
depends_on:
|
|
|
|
- db
|
|
|
|
ports:
|
|
|
|
- "5000:5000"
|
|
|
|
environment:
|
|
|
|
- "POSTGRES_CONNECTION_PARAMETERS=host=db port=5432 user=capsul password=capsul dbname=capsul"
|
2021-08-16 00:30:46 +00:00
|
|
|
- SPOKE_MODEL
|
|
|
|
- FLASK_DEBUG
|
Docker image, & local development docker-compose.yml (#2)
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: https://git.autonomic.zone/3wordchant/capsul-flask/pulls/2
Co-authored-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
Co-committed-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
2021-07-21 23:18:10 +00:00
|
|
|
- BASE_URL=http://localhost:5000
|
|
|
|
- ADMIN_PANEL_ALLOW_EMAIL_ADDRESSES=3wc.capsul@doesthisthing.work
|
|
|
|
- VIRSH_DEFAULT_CONNECT_URI=qemu:///system
|
|
|
|
# The image uses gunicorn by default, let's override it with Flask's
|
|
|
|
# built-in development server
|
|
|
|
command: ["flask", "run", "-h", "0.0.0.0", "-p", "5000"]
|
|
|
|
db:
|
|
|
|
image: "postgres:9.6.5-alpine"
|
|
|
|
volumes:
|
|
|
|
- "postgres:/var/lib/postgresql/data"
|
|
|
|
environment:
|
|
|
|
POSTGRES_USER: capsul
|
|
|
|
POSTGRES_PASSWORD: capsul
|
|
|
|
POSTGRES_DB: capsul
|
|
|
|
|
|
|
|
volumes:
|
|
|
|
postgres:
|