I finally managed to implement it. I will try to describe the required steps.
- Install Jenkins with 2 plugins GitHub plugin + Publish Over SSH.
- Create a new jenkins job. Then you you connect your job with your repo plus the server (raspberry) that you want to ssh. You also specify the Source files to transfer (Dockerfile etc) within a folder (example/) plus an exec command sh deploy.sh
$image = docker/repo docker build -t $image example/ docker push $image
- In dockerhub you create your repo and webhooks for every single raspberry.
- In your raspberry you run a server that listens for docker images pull.
https://github.com/donMichaelL/e-pres/tree/master/docker-ubuntu/docker-server - On github you need to create a webhook with your jenkins server
When a change is pushed to Github, a web hook will trigger your Jenkins to run a build. Jenkins will connect your raspberry through SSH (Publish Over SSH., jenkins plugin) send github files, and run the script (deploy.sh). The script will build an image and pull it to Dockerhub. Dockerhub will send HTTP POST request to all webhooks. Your raspberries will listen for such request, and automatically will run the new image.