@@ -53,3 +53,39 @@ 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. Go to your AWS console and click "Launch Instance"
64+1. Go to the "Community AMIs" section and search for `NixOS 17.09`; then pick the latest AMI.
65+1. In the instance configuration wizard ensure that your instance has at least 1GB RAM and 10GB disk space.
66+1. When prompted save your AWS private key (`~/myaws.pem`) somewhere safe. We'll need it later during deployment.
67+1. Go to "Security Groups", select your instance's security group and under "Inbound" tab add a new rule for HTTP port 80.
68+
69+At this stage your instance should be booting and become accessible shortly. Note down the hostname of your instance. It should look like this:
70+
71+```
72+INSTANCE_HOSTNAME=ec2-??-??-??-??.ca-central-1.compute.amazonaws.com
73+```
74+
75+Now go to your Obelisk project directory (`~/code/myapp`), and initialize a deployment config (`~/code/myapp-deploy`):
76+
77+```
78+cd ~/code/myapp
79+ob deploy init --ssh-key ~/myaws.pem --hostname ${INSTANCE_HOSTNAME} ~/code/myapp-deploy
80+```
81+
82+Then go to that created deployment configuration directory, and initiate the deployment:
83+
84+```
85+cd ~/code/myapp-deploy
86+ob deploy push
87+```
88+
89+`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.
90+
91+At this point you are done. Your app will be accessible at `http://${HOSTNAME}`!