@@ -53,3 +53,48 @@ To increase developer productivity it is highly recommended to make use of the
5353will compile and refresh itself showing you the latest possible syntax or type errors
5454as well as any other ghc warnings whenever files within their respective directories
5555are saved and updated.
56+
57+## Deploying
58+
59+In this section we will demonstrate how to deploy your Obelisk app to an Amazon EC2 instance.
60+
61+First create a new EC2 instance:
62+
63+1. Launch a NixOS 17.09 EC2 instance (we recommend [this AMI](https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-40bee63a))
64+1. In the instance configuration wizard ensure that your instance has at least 1GB RAM and 10GB disk space.
65+1. When prompted save your AWS private key (`~/myaws.pem`) somewhere safe. We'll need it later during deployment.
66+1. Go to "Security Groups", select your instance's security group and under "Inbound" tab add a new rule for HTTP port 80.
67+
68+At this stage your instance should be booting and become accessible shortly. Note down the hostname of your instance. It should look like this:
69+
70+```
71+INSTANCE_HOSTNAME=ec2-??-??-??-??.ca-central-1.compute.amazonaws.com
72+```
73+
74+Now go to your Obelisk project directory (`~/code/myapp`), and initialize a deployment config (`~/code/myapp-deploy`):
75+
76+```
77+cd ~/code/myapp
78+ob deploy init --ssh-key ~/myaws.pem --hostname ${INSTANCE_HOSTNAME} ~/code/myapp-deploy
79+```
80+
81+Then go to that created deployment configuration directory, and initiate the deployment:
82+
83+```
84+cd ~/code/myapp-deploy
85+ob deploy push
86+```
87+
88+`ob deploy push` will locally build your app and then transfer it, along with all the Nix package dependencies, via ssh to the EC2 instance. It will also configure Nginx so that the public port 80 proxies to the running app.
89+
90+At this point you are done. Your app will be accessible at `http://${HOSTNAME}`!
91+
92+### Deploying an updated version
93+
94+If you'd like to deploy an updated version (with new commits) of your Obelisk app: simply go to the configuration directory, update the source thunk and push:
95+
96+```
97+cd ~/code/myapp-deploy
98+ob deploy update
99+ob deploy push
100+```