Deploying to home server from private github repo. reddit / selfhosted ---------------------------------------------------------------------- Future_Extreme · 2023-12-20 19:23 I have an django + react app that is placed on private repo on github. I prepared a docker-compose and use it on one of my proxmox vms. However making a MR, ssh to server, doing a git pull and docker compose up --build -d isn't the way I want to develop my app. I know that I can add some ops magic to github actions, but I don't want to store any infrastructure knowledge in my codebase. I could also create a cronjob that pull and build every hour, but I believe that there are more sophisticated ways to accomplish such goal. Are there any tools that check whether my repo was updated and if so pull changes and deploy the app? The flow that I want to achieve is: 1. I make some changes and merge to master branch. 2. github make a webhook request. 3. There is a process of cloning or pulling the repo, building images and then deploying by compose up. 4. I don't want to store any previous images, so on every deploy all past images should be removed. ---------------------------------------------------------------------- Old_Bug4395 · 2023-12-20 19:36 You should be able to use environment variables in your github repository settings so that you're not storing sensitive information in the repo itself. ---------------------------------------------------------------------- Future_Extreme · 2023-12-20 19:57 Yep, but this solution force me to change github actions. What if i want to make a repo public some day? The infra specific knowledge in public repo isn't a good idea imo. I believe that there is a solution that is capable of deploying the code the way that codebase remains untouched. ---------------------------------------------------------------------- Old_Bug4395 · 2023-12-20 20:10 The sensitive information is stored in environment variables that are not accessible to people who do not have admin access to your repository. You could write a cron to just periodically pull the git repo if you're really that opposed to using environment variables, but this is the industry standard. ---------------------------------------------------------------------- Stetsed · 2023-12-20 21:19 So there is watchtower, which allows you to automatically update docker containers which could be used for this(and is how I do it for my web apps like my website). This doesn't require using github actions at all, but it's pull style instead of push so you gotta set a schedule for watchtower but this is imho the easiest solution that's still robust ---------------------------------------------------------------------- Future_Extreme · 2023-12-20 21:26 Where do you store you docker images? Docker hub? Some selfhosted solution? ---------------------------------------------------------------------- Stetsed · 2023-12-20 21:28 I currently use Gitea with Gitea actions to automatically build the images and then store them inside of the gitea container registry. ---------------------------------------------------------------------- FuriousRageSE · 2023-12-20 21:29 Not 100% sure what you ask. But i know you can have github visit a pre-defined url, to "ping" you that there is a new commit on that project, and then you can chose to act on this ping. https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28 ---------------------------------------------------------------------- LazySht · 2023-12-20 22:20 You can use Drone to achieve that with minimal effort. ---------------------------------------------------------------------- da-nadda · 2023-12-20 22:22 Thank you so much! I was searching for tool for that! ---------------------------------------------------------------------- thetman0 · 2023-12-20 23:20 For sensitive info in my projects I add the .env to .gitignore. Then back it up a different way. ---------------------------------------------------------------------- Future_Extreme · 2023-12-20 23:50 Unfortunatelly drone needs a .drone.yaml file in the repository and I don't want to add anything related to deployment to repository. I want a repo as is + webhook - > ability to deploy whole project with scenario I want. ---------------------------------------------------------------------- CloudContainer · 2023-12-21 01:41 Portainer is really handy. I've got it hooked up to my private GitHub repo with a Personal Access Token, and it smoothly deploys docker- compose.yml files by automatically checking for new commits every 5 minutes. I run all my docker instances this way. ---------------------------------------------------------------------- throwawayacc201711 · 2023-12-21 12:51 In GitHub you can create environments & secrets and use those in the GHA. Use env vars if they aren’t sensitive info and secrets for sensitive ones. The secrets will show up masked (****) in GHA output logs. ---------------------------------------------------------------------- Future_Extreme · 2023-12-21 15:43 That’s true, but I asked for a solution that handle the repo in its current state. I don’t want to put any files related to deployment in project repository. Dockerfile and docker-compose must be enough for deployment. ---------------------------------------------------------------------- Future_Extreme · 2023-12-21 15:45 I tried the portainer gitops functionality, but I couldn’t manage to rebuild the images on every pull. Today I found a issue on github with my problem - https://github.com/portainer/portainer/issues/6288 and it seems the solution is trivial :) ---------------------------------------------------------------------- Reasonable-Ladder300 · 2023-12-21 18:34 Same here, using gitea actions for my whole ci/cd pipeline. ---------------------------------------------------------------------- throwawayacc201711 · 2023-12-21 21:59 Then just make a bash script to do this - seems pretty straight forward if you’re just trying to do this on the host machine. You’re just using other cli commands ---------------------------------------------------------------------- CloudContainer · 2023-12-21 23:02 Yes, "pull_policy: build" is great to have. I’ve tried other solutions, but Portainer does what I need.