p-zombie / freqtrade

Automatically deploy freqtrade to a remote Docker host and auto update strategies.
152 stars 56 forks source link

Create README.md #5

Closed pippinmole closed 2 years ago

pippinmole commented 2 years ago

I'm not going to include it in the README because I don't know enough to know if it will affect anything, but it should be git push heroku main and not git push heroku master - Heroku and Git have noted that they are moving away from the use of the word master.

joaorafaelm commented 2 years ago

Hi, thanks for your PR. This repo is actually not related to heroku, I've been using it to automatically deploy to vultr, using docker deploy and to automatically update strategies based on gh actions. take a look at the gh actions to understand how it works https://github.com/p-zombie/freqtrade/tree/master/.github/workflows Unfortunately I did a bad job at documenting how to setup, but I'll write a decent readme soon.

Here is an overview of how it works right now: First of all, you need a docker host to deploy the app, like https://www.vultr.com/docs/one-click-docker/ or any other provider you want. Then, you need to have a docker hub account Optionally, you may setup a telegram bot to receive deployment messages.

Once you have everything above, fork the repo, then you'll need to setup a few GitHub secrets to make it work:

DOCKER_USERNAME -- docker hub username DOCKER_PASSWORD -- docker hub password DOCKER_HOST -- used by https://github.com/wshihadeh/docker-deployment-action DOCKER_SSH_PRIVATE_KEY -- used by https://github.com/wshihadeh/docker-deployment-action DOCKER_SSH_PUBLIC_KEY -- used by https://github.com/wshihadeh/docker-deployment-action TELEGRAM_TO -- chat id which will receive deployment messages TELEGRAM_TOKEN -- telegram bot token GH_PAT -- personal GitHub token, used by https://github.com/p-zombie/freqtrade/blob/master/.github/workflows/update_strat.yml

Every-time you commit something to the repo, it will trigger a new docker build and push the image to docker hub (https://github.com/p-zombie/freqtrade/blob/master/.github/workflows/main.yml), and it will deploy production.yml to the host you setup using a docker deployment action. PS; you may need to modify production.yml and change the image name to match your docker hub username, if not, it will use the image under my username.

I also added a scheduled job to run using GitHub actions: https://github.com/p-zombie/freqtrade/blob/master/.github/workflows/update_strat.yml it is set to run every minute but GitHub actually runs it about every 5 minutes; it pulls strategies, blacklists and pairlist files from https://github.com/iterativv/NostalgiaForInfinity and if the files changed, it will commit to the repo, which will trigger a new deploy and send a message in the telegram chat specified in the secrets.

That's about it, the hardest part is probably setting up the secrets for docker-deployment-action, but it should be pretty straightforward. I also added a docker prune file to prevent docker cache consuming all space in your docker host, copy to your docker host and run chmod +x docker-prune && mv docker-prune /etc/cron.daily and it should run every day.

if you plan to run it locally, it works exactly as the heroku repo, take a look at the makefile to check the available commands, or simply run make or make help to get a list of commands.

pippinmole commented 2 years ago

Hi,

I tried adding the user secrets, however you cannot use special characters for GitHub secrets (secrets.DOCKER_USERNAME)

Screenshot 2022-01-01 at 23 25 28

.

joaorafaelm commented 2 years ago

you don't need to add "secrets." to the secret name it should be only the actual name, ex: DOCKER_USERNAME, DOCKER_PASSWORD etc.