<p>We do this at work.</p>

<p>We have a small server, let's call it the receiver, it's the target of the <a href="https://developer.github.com/webhooks/" rel="noreferrer">GitHub webhook events</a>. It runs a small application that parses the payload and incorporates logic around how to proceed e.g. create a new server on the infrastructure provider, update the load balancer, deploy to an existing server, destroy the server etc. This could be a traditional web application serving up an API or it could be a serverless application, up to you how you want to approach it.</p>

<p>The receiver is relatively straightforward to handle, the other necessary supporting systems you'll need are an approach to configuration management/provisioning (how does the server have the packages necessary to run the application), secrets management (how does the server get access to sensitive information) and routing  (how do the subdomains get updated and route to the correct server).</p>

<p>It could be worthwhile looking at preparing an <a href="https://aws.amazon.com/answers/configuration-management/aws-ami-design/" rel="noreferrer">AMI</a> with the necessary services configured, a <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html" rel="noreferrer">CloudFormation</a> template with the infrastructure provisioning logic and <a href="http://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html" rel="noreferrer">CodeDeploy</a> could handle deployments for you.</p>

<p><strong>Configuration Management</strong></p>

<p>This is really up to you and your team, there are a multitude of tools you can use or you can simply rely on shell scripting. At what point in the servers lifecycle you apply the changes is what's discussed in the AMI design <a href="https://aws.amazon.com/answers/configuration-management/aws-ami-design/" rel="noreferrer">article</a> I linked. </p>

<p><strong>Secrets Management</strong></p>

<p>This is a challenging topic to address with the information at hand, in the interest of brevity I'll leave that up to you and your team.</p>

<p><strong>Routing</strong></p>

<p>There are a few ways you can handle routing, the Application Load Balancer (not to be confused with the ELB/NLB) offered by AWS supports <a href="http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#host-conditions" rel="noreferrer">host based routing</a>. Alternatively you could use a reverse proxy like NGINX or HAProxy, when you provision a new environment you will need to update this routing (ideally automatically) irrespective of what approach you take.</p>

<p>Don't forget to consider how you'll handle the database/persistence layer &amp; zero down time deployments. The question to ask with the persistence layer is whether the team will share a database and how that will interact with things like migrations. On the topic of zero downtime deployments, CodeDeploy should handle that nicely for you. One more thing, you mentioned a single mobile application pointing to different environments, how will you point these applications to the environments.</p>

CC BY-SA 3.0
2017-11-19T07:51:07.703Z
There is a lot of juice in your answer. Can you break it down a bit though? For example in the different sections you mentioned.. can you give me something to start with in each if them?
abbood
CC BY-SA 3.0
2017-11-19T10:49:24.427Z
Is there any relationship between [the user who posted this answer](https://devops.stackexchange.com/users/5269/dom-hutton), and [this user](https://devops.stackexchange.com/users/670/dom-hutton)? I bet they are from the same "user" ... If so please have both accounts merged ...
Pierre.Vriens
CC BY-SA 3.0
2017-11-19T04:41:17.197Z
2017-11-19T10:39:38.640Z
2017-11-19T10:39:38.640Z
dom_hutton
<p>this setup worked perfectly for me using aws code deploy:</p>

<p><a href="https://i.sstatic.net/mo6zT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mo6zT.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2018-08-02T16:47:57.550Z
2018-08-02T16:47:57.550Z
abbood
<h1>Background</h1>

<p>I got a team of untechnical QA's who have to do testing on iOS/android apps for every Pull Request (PR) that gets created by my backend team. </p>

<h1>Question</h1>

<p>This is what I want to do: everytime a backend engineer creates a PR on bitbucket, I would like a script to automatically deploy the code of that PR git branch into a subdomain of our dev server that matches the JIRA issue created. </p>

<p>For example suppose the jira issue that the PR addresses is BAC-421, then as soon as the engineer creates a PR, the script deploys the code they created into AWS EC2 so that the QA can point their apps to www.bac421.mydevdomain.com</p>

<p>What is the best way to do this? I'm a devops technical nube. </p>

<h1>Update - Environment Specs</h1>

<p>so here is a breakup of our env
- the backend uses laravel 5.3
- it's deployed on AWS EC2
- we use <a href="https://forge.laravel.com/auth/login" rel="noreferrer">forge</a> for auto deployment (nothing fancy.. we just run this script:</p>

<pre><code>cd /home/forge/default
git fetch --tags 
git pull origin master
git describe
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.1-fpm reload

if [ -f artisan ]
then
    php artisan migrate --force
    php artisan config:cache
    php artisan queue:restart
fi
</code></pre>

<p>that we run as soon as we merge dev unto master branch)
- besides that we don't use any CI/CD tools although I'm open for recommendations
- DNS provider is GoDaddy
- our application server is nginx
- our database is in a separate RDS instance</p>

CC BY-SA 3.0
2017-11-19T01:09:32.827Z
How do you currently deploy your software? What CI or CD tools do you use? Who is your DNS provider?
user2640621
CC BY-SA 3.0
2017-11-19T01:28:53.943Z
Yes. There are plenty of ways to skin this cat - including but not limited to updating a hosts file, but we would need to know more about your environment.
James Shewey
CC BY-SA 3.0
2017-11-19T06:46:55.043Z
answer updated @user2640621
abbood
<git><deployment><bitbucket><git-hooks>
how to automatically create a subdomain for every pull request
abbood
# how to automatically create a subdomain for every pull request

(Asked by: username_0 on 2017-11-18)

Background
I got a team of untechnical QA's who have to do testing on iOS/android apps for every Pull Request (PR) that gets created by my backend team. 
Question
This is what I want to do: everytime a backend engineer creates a PR on bitbucket, I would like a script to automatically deploy the code of that PR git branch into a subdomain of our dev server that matches the JIRA issue created. 
For example suppose the jira issue that the PR addresses is BAC-421, then as soon as the engineer creates a PR, the script deploys the code they created into AWS EC2 so that the QA can point their apps to www.bac421.mydevdomain.com
What is the best way to do this? I'm a devops technical nube. 
Update - Environment Specs
so here is a breakup of our env
- the backend uses laravel 5.3
- it's deployed on AWS EC2
- we use forge for auto deployment (nothing fancy.. we just run this script:
cd /home/forge/default
git fetch --tags 
git pull origin master
git describe
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.1-fpm reload

if [ -f artisan ]
then
    php artisan migrate --force
    php artisan config:cache
    php artisan queue:restart
fi

that we run as soon as we merge dev unto master branch)
- besides that we don't use any CI/CD tools although I'm open for recommendations
- DNS provider is GoDaddy
- our application server is nginx
- our database is in a separate RDS instance

**Tags:** git, deployment, bitbucket, git-hooks

> **Comments:**
> **username_1**: How do you currently deploy your software? What CI or CD tools do you use? Who is your DNS provider?  
> **username_2**: Yes. There are plenty of ways to skin this cat - including but not limited to updating a hosts file, but we would need to know more about your environment.  
> **username_0**: answer updated @username_1  

---

## 2 answers

### Answer by username_0 on 2018-08-02. Score: 3 | Accepted answer

this setup worked perfectly for me using aws code deploy:

[![enter image description here](https://i.sstatic.net/mo6zT.png)](https://i.sstatic.net/mo6zT.png)


---

### Answer by username_3 on 2017-11-19. Score: 7

We do this at work.

We have a small server, let's call it the receiver, it's the target of the [GitHub webhook events](https://developer.github.com/webhooks/). It runs a small application that parses the payload and incorporates logic around how to proceed e.g. create a new server on the infrastructure provider, update the load balancer, deploy to an existing server, destroy the server etc. This could be a traditional web application serving up an API or it could be a serverless application, up to you how you want to approach it.

The receiver is relatively straightforward to handle, the other necessary supporting systems you'll need are an approach to configuration management/provisioning (how does the server have the packages necessary to run the application), secrets management (how does the server get access to sensitive information) and routing (how do the subdomains get updated and route to the correct server).

It could be worthwhile looking at preparing an [AMI](https://aws.amazon.com/answers/configuration-management/aws-ami-design/) with the necessary services configured, a [CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) template with the infrastructure provisioning logic and [CodeDeploy](http://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html) could handle deployments for you.

**Configuration Management**

This is really up to you and your team, there are a multitude of tools you can use or you can simply rely on shell scripting. At what point in the servers lifecycle you apply the changes is what's discussed in the AMI design [article](https://aws.amazon.com/answers/configuration-management/aws-ami-design/) I linked.

**Secrets Management**

This is a challenging topic to address with the information at hand, in the interest of brevity I'll leave that up to you and your team.

**Routing**

There are a few ways you can handle routing, the Application Load Balancer (not to be confused with the ELB/NLB) offered by AWS supports [host based routing](http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#host-conditions). Alternatively you could use a reverse proxy like NGINX or HAProxy, when you provision a new environment you will need to update this routing (ideally automatically) irrespective of what approach you take.

Don't forget to consider how you'll handle the database/persistence layer & zero down time deployments. The question to ask with the persistence layer is whether the team will share a database and how that will interact with things like migrations. On the topic of zero downtime deployments, CodeDeploy should handle that nicely for you. One more thing, you mentioned a single mobile application pointing to different environments, how will you point these applications to the environments.

> **Comments:**
> **username_0**: There is a lot of juice in your answer. Can you break it down a bit though? For example in the different sections you mentioned.. can you give me something to start with in each if them?  
> **username_4**: Is there any relationship between [the user who posted this answer](https://devops.stackexchange.com/users/5269/dom-hutton), and [this user](https://devops.stackexchange.com/users/670/dom-hutton)? I bet they are from the same "user" ... If so please have both accounts merged ...  

---

