Answers: <p><a href="https://github.com/ocd-scm/ocd-environment-webhook/blob/master/hooks-release.json" rel="nofollow noreferrer">Here</a> is a Webhook rule to catch Github release events and run a custom bash script. It is run by <a href="https://github.com/adnanh/webhook" rel="nofollow noreferrer">adnanh/webhook</a> which is a small go app that can run your deployment script. You then configure GitHub to send release events as per this screenshot:</p>
  
  <p><a href="https://i.sstatic.net/4Tu0E.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4Tu0E.png" alt="enter image description here"></a></p>
  
  <p>You can then use the github <a href="https://github.com/github/hub" rel="nofollow noreferrer">hub</a> command line tool to create releases with a name that matches the regex in the hook rule e.g., <code>v1.2.3</code>. That will fire the release webhook. That can be caught by your deploy script running in a container on your server. Your deploy script can take the release number parsed from the release event payload. It can then git pull the git tag <code>v1.2.3</code> launch your code. Note that you don’t have to use the hub cli a release event will also be fired if you push a tag to your repo using regular git. We find it helpful to use the hub tool that creates the tag and a github release. You can attach automatically generated release notes using <a href="https://github.com/github-changelog-generator/github-changelog-generator" rel="nofollow noreferrer">github_changelog_generator</a> see this example <a href="https://github.com/sobolevn/git-secret/blob/44a8745e0295d6e35f33346db1300216714e8e13/.ci/github_release_script.sh#L17" rel="nofollow noreferrer">script</a>. </p>
  
  <p>Using similar webhooks is how <a href="https://github.com/ocd-scm/ocd-meta" rel="nofollow noreferrer">OCD</a> can drive kubernetes from configuration in GitHub. We have OCD deploy all our apps on AWS based on configuration and tags in GitHub. You can use the same techniques to drive your small deployment scripts quite easily. All you need to do is create docker container with adnanh/webhook, the json config and your deploy script. <a href="https://github.com/ocd-scm/ocd-tools/blob/33791b92bb202f593dea1001a7ea802adad646a9/Dockerfile#L51" rel="nofollow noreferrer">Here</a> is a where we install webhook into a container and <a href="https://github.com/ocd-scm/ocd-environment-webhook/blob/6d9c3904929b7b8a6e9fd2883bce5b40f43952d3/Dockerfile#L14" rel="nofollow noreferrer">here</a> is where we copy our rules. As it is a go app it doesn’t need a lot of memory to be able to fully automate your software based on git webhook events. </p>
  
Answers: CC BY-SA 4.0
Answers: 2019-04-10T09:57:54.620Z
Answers: Wow amazing! This makes it so much easier! Thank you for brief explanation, hats off to you, sir
Answers: Ignas Damunskis
Answers: CC BY-SA 4.0
Answers: 2019-04-10T15:04:56.787Z
Answers: OCD will take release events and build a new container when the code and tag that container with the same tag. It will also catch push events to master in a config repo then sync all the configuration into our environments such as encrypted passwords. Obviously that is all for Kubernetes but it's all just shell scripts driven by that little Webhook go app which is so very useful.
Answers: simbo1905
Answers: CC BY-SA 4.0
Answers: 2019-04-14T10:01:07.553Z
Answers: I have added a note about github_changelog_generator which you might find helpful
Answers: simbo1905
Answers: CC BY-SA 4.0
Answers: 2019-04-10T05:33:49.167Z
Answers: 2019-04-14T16:04:26.390Z
Answers: 2019-04-14T16:04:26.390Z
Answers: simbo1905
Body: <p>I have a VPS and am able to connect trough ssh using Terminal.
  Every project I have are dockerized and have github repositories.
  Since I am new to deployments so far my deployment process is manual:</p>
  
  <pre><code>$ ssh root@xxx.xxx.xx.xxx
  $ cd /root/www/project_dir
  $ git pull
  $ docker-compose up --build -d --force-recreate
  </code></pre>
  
  <p>I would like to know how should I correctly deploy dockerized github applications on VPS? Is there a better practice or script, maybe a tool?</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-04-08T21:56:13.277Z
Comments: where is your git repo hosted?
Comments: simbo1905
Comments: CC BY-SA 4.0
Comments: 2019-04-09T07:21:05.083Z
Comments: @simbo1905 GitHub
Comments: Ignas Damunskis
Tags: <docker><docker-compose><deployment><github>
Title: How should I deploy my projects using Docker, Git and VPS?
UserDisplayName: Ignas Damunskis
ThreadText: # How should I deploy my projects using Docker, Git and VPS?
  
  (Asked by: username_0 on 2019-04-08)
  
  I have a VPS and am able to connect trough ssh using Terminal.
  Every project I have are dockerized and have github repositories.
  Since I am new to deployments so far my deployment process is manual:
  
  ```
  $ ssh root@xxx.xxx.xx.xxx
  $ cd /root/www/project_dir
  $ git pull
  $ docker-compose up --build -d --force-recreate
  
  ```
  
  I would like to know how should I correctly deploy dockerized github applications on VPS? Is there a better practice or script, maybe a tool?
  
  **Tags:** docker, docker-compose, deployment, github
  
  > **Comments:**
  > **username_1**: where is your git repo hosted?  
  > **username_0**: @username_1 GitHub  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-10. Score: 2 | Accepted answer
  
  [Here](https://github.com/ocd-scm/ocd-environment-webhook/blob/master/hooks-release.json) is a Webhook rule to catch Github release events and run a custom bash script. It is run by [adnanh/webhook](https://github.com/adnanh/webhook) which is a small go app that can run your deployment script. You then configure GitHub to send release events as per this screenshot:
  
  [![enter image description here](https://i.sstatic.net/4Tu0E.png)](https://i.sstatic.net/4Tu0E.png)
  
  You can then use the github [hub](https://github.com/github/hub) command line tool to create releases with a name that matches the regex in the hook rule e.g., `v1.2.3`. That will fire the release webhook. That can be caught by your deploy script running in a container on your server. Your deploy script can take the release number parsed from the release event payload. It can then git pull the git tag `v1.2.3` launch your code. Note that you don’t have to use the hub cli a release event will also be fired if you push a tag to your repo using regular git. We find it helpful to use the hub tool that creates the tag and a github release. You can attach automatically generated release notes using [github\_changelog\_generator](https://github.com/github-changelog-generator/github-changelog-generator) see this example [script](https://github.com/sobolevn/git-secret/blob/44a8745e0295d6e35f33346db1300216714e8e13/.ci/github_release_script.sh#L17).
  
  Using similar webhooks is how [OCD](https://github.com/ocd-scm/ocd-meta) can drive kubernetes from configuration in GitHub. We have OCD deploy all our apps on AWS based on configuration and tags in GitHub. You can use the same techniques to drive your small deployment scripts quite easily. All you need to do is create docker container with adnanh/webhook, the json config and your deploy script. [Here](https://github.com/ocd-scm/ocd-tools/blob/33791b92bb202f593dea1001a7ea802adad646a9/Dockerfile#L51) is a where we install webhook into a container and [here](https://github.com/ocd-scm/ocd-environment-webhook/blob/6d9c3904929b7b8a6e9fd2883bce5b40f43952d3/Dockerfile#L14) is where we copy our rules. As it is a go app it doesn’t need a lot of memory to be able to fully automate your software based on git webhook events.
  
  > **Comments:**
  > **username_0**: Wow amazing! This makes it so much easier! Thank you for brief explanation, hats off to you, sir  
  > **username_1**: OCD will take release events and build a new container when the code and tag that container with the same tag. It will also catch push events to master in a config repo then sync all the configuration into our environments such as encrypted passwords. Obviously that is all for Kubernetes but it's all just shell scripts driven by that little Webhook go app which is so very useful.  
  > **username_1**: I have added a note about github_changelog_generator which you might find helpful  
  
  ---
  
  