I want to implement CI/CD for my application, so far I have managed to build and upload my image on docker hub with GitHub actions. Now I need a way to pull that image on my VPS and run the docker image. I do not know how to achieve that, I tried multiple youtube videos but none show that.
Could someone point me to the right direction?
3
Answers
Usually flow after image exists in Dockerhub is:
For an example with Nginx, the image resides in Dockerhub and with help of official docs you can see
the command which will pull the Nginx image (latest in this case) and run the container with the name of mynigninx1 and expose the port on host 80 and map it to port 80 inside the container.
What I have done is:
Setup a webhook on vps, this serves as a webhook server, define a endpoint and a script to redeploy (Will be executed when endpoint is called and met)
In your GitHub ctions flow, add new a step, send a request to this webhook server endpoint
There is a docker image you can run on your server to watch your working or selected docker containers and when there is a new push to the docker hub registry then it will update your docker image of your project
Its called watchtower
containrrr/watchtower