[Hackathon] About making a tool that can be CD on Raspberry Pi [Convenient tool]

Introduction

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!

GitHub PyPI

~~ This will definitely give you the highest award next year ~~

CanDyPi

CanDyPi is a Continuous Delivery tool for raspberry Pi.

candypi_structure.png.001.png

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.

How to use

Advance preparation

--python 3 series

procedure

Can be used in 4 steps

1. Raspberry Pi, git SSH connection

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 ~

2. Install & run CanDyPi on Raspberry Pi

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

3. Start ngrok with Raspberry Pi

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 

4. WebHooks settings on GitHub

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.)

5. Completion

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.

at the end

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

[Hackathon] About making a tool that can be CD on Raspberry Pi [Convenient tool]
[Django] About users that can be used on template
Introduced "Glances" command, a monitoring tool that can be understood at a glance, on Mac
A memo for making a figure that can be posted to a journal with matplotlib
Moved Raspberry Pi remotely so that it can be LED attached with Python
A story about making an x86 bootloader that can boot vmlinux with Rust
Build a Django environment on Raspberry Pi (MySQL)
Try using a QR code on a Raspberry Pi
Build a Python development environment on Raspberry Pi
File sharing server made with Raspberry Pi that can be used for remote work
Deep learning course that can be crushed on site
A memorandum when making a surveillance camera with Raspberry Pi
[Atcoder] [C ++] I made a test automation tool that can be used during the contest
pigpio on Raspberry pi
Cython on Raspberry Pi
From a book that programmers can learn ... (Python): About sorting
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
SSD 1306 OLED can be used with Raspberry Pi + python (Note)
Listen to a novel that will be on Amazon Polly
Implement a thread that can be paused by exploiting yield
Let's make a diagram that can be clicked with IPython
[Python] Draw elevation data on a sphere with Plotly and draw a globe that can be rotated round and round
About the matter that torch summary can be really used when building a model with Pytorch
Use the graphic LCD as a character LCD that can also display Chinese characters on the Rasberry Pi
The story of making a tool that runs on Mac and Windows at the game development site
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi