In recent web application development, CI (Continuous Integration) and CD (Continuous Delivery) are substantial, and if you push to a remote repository, the production environment will be updated automatically, which is convenient.
However, if the production environment is a local terminal, it is not possible to have the CI tool CD it, and you have to pull the remote change every time, so it is ** troublesome **
Even more in the absence of time like a hackathon If the production environment is Raspberry Pi, I want to reduce the time and effort of typing commands instead of developing with Raspberry Pi.
So, I made ** CanDyPi **, a CD tool that pulls every time the remote repository is updated if you put it in RaspberryPi!
~~ This will definitely give you the highest award next year ~~
CanDyPi
CanDyPi is a Continuous Delivery tool for raspberry Pi.
Easy to make. Use the webhook function of GitHub to hook the webhook to the ngrok endpoint forwarded from the Raspberry Pi. When CanDyPi receives the repository update message, run the pull command to update to the latest source.
CanDyPi is written in python and uses flask
for the server and git python
for git operations.
--python 3 series
Can be used in 4 steps
If you do not set it to SSH, you will have to enter the password every time you pull, so you will not be released from the Raspberry Pi operation ...
Articles around here will be helpful. Procedure for ssh connection on GitHub ~ From generation of public / private key ~
You can install it with pip. ㊟ Please install & execute with python3 series
$ pip install candypi
Easy to execute! Give the path of the repository you want to CD as an argument. (By default, it starts up on port 50000)
$ candypi /Users/tiwasa/sample_project
Specify the port on which candypi was started, and start ngrok.
$ ngrok http 50000
ngrok by (Ctrl+C to quit)
Session Status online
Account XXXXXXXX (Plan: Free)
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://XXXXXXXX.ngrok.io -> localhost:50000
Forwarding https://XXXXXXXX.ngrok.io -> localhost:50000
Register the webhook in the repository you want to CD.
In Settings-> Webhooks on GitHub, add ngrok's Forwarding https://XXXXXXXX.ngrok.io-> localhost: 50000
to the Payload URL of add webhook and add webhook.
(Other items can be left as default.)
When the master branch of the repository you want to CD is updated, the pull command will run on the local repository in the Raspberry Pi to keep it up to date.
I made it during the year-end and New Year holidays, so I haven't put it into practice yet. Isn't there an affordable hackathon?
If you find yourself using it, please write it in the GitHub issue or in the comments section of this page.
By the way, if you can place the development PC on the same local network as Raspberry Pi, I think vscode remote development is more convenient. Also, depending on the venue, it may be placed on another LAN, so there is value in the existence of CanDyPi.
···When
... I want to think
Recommended Posts