An extremely simple platform which enables you to host a docker container in exchange for digital currency (bitcoin/litecoin/dogecoin)
In otherwords - provision a container using docker-compose when someone pays you with cryptocurrency - host that container for them, accessible as a URL path on your server (that URL path is automatically generated from two random words)
Yes I'm sure there's a better way todo this, but this works for me :), and it was the fastest way I could get some proof of concept working
data/docker-compose-paid-instances.yml is re-generated with the paid container information (and a container name which is also the container hostname), managed by a simple SQLite DBdocker-compose up runs periodically, it knows when a YAML has changed thanks to its internal checksums, so lazy so implementation..proxy_passThen the new 'customer' simply accesses their hosted container via nginx's proxy_pass as a path on your server, it's recommended to run the containers as a sub-domain, otherwise the nginx rules get a bit complicated ie, https://pay-me.mydomain.io/ , so the hosted container would be available as https://pay-me.mydomain.io/random-name
Some extra bonus stuff happens like
# m h dom mon dow command
*/2 * * * * curl -s https://your-site.com/sync >/dev/null && cd /var/www/provisioner && docker-compose --log-level=WARNING -f docker-compose.yml -f docker-compose.prod.yml -f data/docker-compose-paid-instances.yml up -d --remove-orphans
There's some very lazy things going on here
docker-compose.yml the stock one, requireddocker-compose.prod.yml your local settings, like setting the crypto network (bitcoin/testnet/litecoin etc) and return coin addressdata/docker-compose-paid-instances.yml the generated extra docker-compose YAML for paid instancesThe lazy magic here, is that docker-compose wont do anything unless one of the YAML's change, up supports --remove-orphans so it's easy to remove containers that are not paid for, and --log-level=WARNING keeps it quiet unless something bad happens.
The only shameful thing is that /sync call, which re-builds the composer and checks for payments, your nginx shouldnt allow this to be accessed other than locally (or change the code and move it to a local command)
Probably nearly all of this can be removed by using an actual decent interface like coinbase's API, which handles payments way better, but, where is the fun in that? :)
So basically, when someone has paid for their container, a random name is generated (stir-commuted herein), and data/docker-compose-paid-instances.yml will contain for example...
paid_instance_stir-commuted:
image: dgtlmoon/changedetection.io:latest
networks:
- provisioner_net
environment:
- USE_X_SETTINGS=1
- SALTED_PASS=abc123
hostname: stir-commuted
volumes:
- paid_instance_stir-commuted-data:/datastore
restart: unless-stopped
And they can access it via https://yoursite.com/stir-commuted via this nginx location statement
image: is set by HOSTED_IMAGE env var
Once it is paid, the server will send the coin balance onto an another address, which should NOT be on the server
electrum --testnetBTC_FORWARD_ADDRESS env var)certbot not included, you will need to sort out how this works.random-name.yoursite.com instead of a path suffix, then you dont have to worry about mapping paths etc and they could enjoy full socket IO access aswell18 commits
Python
61.0%
HTML
22.7%
CSS
11.6%
Dockerfile
2.8%
Jinja
1.2%
An extremely simple platform which enables you to host a docker container in exchange for digital currency (bitcoin/litecoin/dogecoin)
In otherwords - provision a container using docker-compose when someone pays you with cryptocurrency - host that container for them, accessible as a URL path on your server (that URL path is automatically generated from two random words)
Yes I'm sure there's a better way todo this, but this works for me :), and it was the fastest way I could get some proof of concept working
data/docker-compose-paid-instances.yml is re-generated with the paid container information (and a container name which is also the container hostname), managed by a simple SQLite DBdocker-compose up runs periodically, it knows when a YAML has changed thanks to its internal checksums, so lazy so implementation..proxy_passThen the new 'customer' simply accesses their hosted container via nginx's proxy_pass as a path on your server, it's recommended to run the containers as a sub-domain, otherwise the nginx rules get a bit complicated ie, https://pay-me.mydomain.io/ , so the hosted container would be available as https://pay-me.mydomain.io/random-name
Some extra bonus stuff happens like
# m h dom mon dow command
*/2 * * * * curl -s https://your-site.com/sync >/dev/null && cd /var/www/provisioner && docker-compose --log-level=WARNING -f docker-compose.yml -f docker-compose.prod.yml -f data/docker-compose-paid-instances.yml up -d --remove-orphans
There's some very lazy things going on here
docker-compose.yml the stock one, requireddocker-compose.prod.yml your local settings, like setting the crypto network (bitcoin/testnet/litecoin etc) and return coin addressdata/docker-compose-paid-instances.yml the generated extra docker-compose YAML for paid instancesThe lazy magic here, is that docker-compose wont do anything unless one of the YAML's change, up supports --remove-orphans so it's easy to remove containers that are not paid for, and --log-level=WARNING keeps it quiet unless something bad happens.
The only shameful thing is that /sync call, which re-builds the composer and checks for payments, your nginx shouldnt allow this to be accessed other than locally (or change the code and move it to a local command)
Probably nearly all of this can be removed by using an actual decent interface like coinbase's API, which handles payments way better, but, where is the fun in that? :)
So basically, when someone has paid for their container, a random name is generated (stir-commuted herein), and data/docker-compose-paid-instances.yml will contain for example...
paid_instance_stir-commuted:
image: dgtlmoon/changedetection.io:latest
networks:
- provisioner_net
environment:
- USE_X_SETTINGS=1
- SALTED_PASS=abc123
hostname: stir-commuted
volumes:
- paid_instance_stir-commuted-data:/datastore
restart: unless-stopped
And they can access it via https://yoursite.com/stir-commuted via this nginx location statement
image: is set by HOSTED_IMAGE env var
Once it is paid, the server will send the coin balance onto an another address, which should NOT be on the server
electrum --testnetBTC_FORWARD_ADDRESS env var)certbot not included, you will need to sort out how this works.random-name.yoursite.com instead of a path suffix, then you dont have to worry about mapping paths etc and they could enjoy full socket IO access aswell18 commits
Python
61.0%
HTML
22.7%
CSS
11.6%
Dockerfile
2.8%
Jinja
1.2%