@@ -13,7 +13,9 @@ Obelisk provides an easy way to develop and deploy your [Reflex](https://github.
13 - [Running over https](#running-over-https)
13 - [Running over https](#running-over-https)
14- [Deploying](#deploying)
14- [Deploying](#deploying)
15 - [Locally](#locally)
15 - [Locally](#locally)
16− - [EC2](#ec2)
16+ - [Default EC2 Deployment](#default-ec2-deployment)
17+ - [Custom Non-EC2 Deployment](#custom-non-ec2-deployment)
18+ - [VirtualBox Deployment](#virtualbox-deployment)
17 - [From macOS](#from-macos)
19 - [From macOS](#from-macos)
18 - [Deploying an updated version](#deploying-an-updated-version)
20 - [Deploying an updated version](#deploying-an-updated-version)
19- [Mobile](#mobile)
21- [Mobile](#mobile)
@@ -55,18 +57,18 @@ Obelisk provides an easy way to develop and deploy your [Reflex](https://github.
56When developing on obelisk itself you may launch `ghcid` for the corresponding project as follows. For example to launch ghcid for `lib/backend` project:
58When developing on obelisk itself you may launch `ghcid` for the corresponding project as follows. For example to launch ghcid for `lib/backend` project:
59nix-shell -A obeliskEnvs.obelisk-backend --run "cd lib/backend && ghcid -c 'cabal new-repl'"
61nix-shell -A obeliskEnvs.obelisk-backend --run "cd lib/backend && ghcid -c 'cabal new-repl'"
62Or to launch ghcid for `lib/command` project:
64Or to launch ghcid for `lib/command` project:
65nix-shell -A obeliskEnvs.obelisk-command --run "cd lib/command && ghcid -c 'cabal new-repl'"
67nix-shell -A obeliskEnvs.obelisk-command --run "cd lib/command && ghcid -c 'cabal new-repl'"
68To re-install `ob` from source do
70To re-install `ob` from source do
70nix-env -f /path/to/obelisk -iA command
72nix-env -f /path/to/obelisk -iA command
@@ -100,13 +102,13 @@ access to:
101To create a new Obelisk project, go to an empty directory and run:
103To create a new Obelisk project, go to an empty directory and run:
107Obelisk leverages ghcid to provide a live-reloading server that handles both frontend and backend. To run your Obelisk app and monitor the source for changes:
109Obelisk leverages ghcid to provide a live-reloading server that handles both frontend and backend. To run your Obelisk app and monitor the source for changes:
@@ -165,7 +167,7 @@ project ./. ({ pkgs, ... }: {
168−### Running over https
170+### Running over HTTPS
170To run your app locally over https, update the protocol in `config/common/route` to `https`, and then use `ob run` as normal.
172To run your app locally over https, update the protocol in `config/common/route` to `https`, and then use `ob run` as normal.
@@ -177,22 +179,22 @@ Since Obelisk generates a self-signed certificate for running https, the browser
178Build everything:
180Build everything:
181nix-build -A exe --no-out-link
183nix-build -A exe --no-out-link
184Copy the result to a new directory, add configuration, and run!
186Copy the result to a new directory, add configuration, and run!
187mkdir test-app
189mkdir test-app
188ln -s $(nix-build -A exe --no-out-link)/* test-app/
190ln -s $(nix-build -A exe --no-out-link)/* test-app/
189cp -r config test-app
191cp -r config test-app
190(cd test-app && ./backend)
192(cd test-app && ./backend)
193−### EC2
195+### Default EC2 Deployment
195−In this section we will demonstrate how to deploy your Obelisk app to an Amazon EC2 instance.
197+In this section we will demonstrate how to deploy your Obelisk app to an Amazon EC2 instance. Obelisk deployments are configured for EC2 by default (see [Custom Non-EC2 Deployment](#custom-non-ec2-deployment)).
197First create a new EC2 instance:
199First create a new EC2 instance:
@@ -219,7 +221,7 @@ ob deploy init \
219 ~/code/myapp-deploy
221 ~/code/myapp-deploy
222−HTTPS is enabled by default; to disable https, pass `--disable-https` to the `ob deploy init` command above.
224+HTTPS is enabled by default; to disable HTTPS pass `--disable-https` to the `ob deploy init` command above.
224This step will also require that you manually verify the authenticity of the host `$SERVER`. Obelisk will save the fingerprint in a deployment-specific configuration. **Obelisk deployments do *not* rely on the `known_hosts` of your local machine.** This is because, in the event that you need to switch from one deploy machine / bastion host to another, you want to be absolutely sure that you're still connecting to the machines you think you are, even if that deploy machine / bastion host has never connected to them before. Obelisk explicitly avoids a workflow that encourages people to accept host keys without checking them, since that could result in leaking production secrets to anyone who manages to MITM you, e.g. via DNS spoofing or cache poisoning. (Note that an active attack is a circumstance where you may need to quickly switch bastion hosts, e.g. because the attacker has taken one down or you have taken it down in case it was compromised. In this circumstance you might need to deploy to production to fix an exploit or rotate keys, etc.) When you run `ob deploy` later it will rely on the saved verification in this step.
226This step will also require that you manually verify the authenticity of the host `$SERVER`. Obelisk will save the fingerprint in a deployment-specific configuration. **Obelisk deployments do *not* rely on the `known_hosts` of your local machine.** This is because, in the event that you need to switch from one deploy machine / bastion host to another, you want to be absolutely sure that you're still connecting to the machines you think you are, even if that deploy machine / bastion host has never connected to them before. Obelisk explicitly avoids a workflow that encourages people to accept host keys without checking them, since that could result in leaking production secrets to anyone who manages to MITM you, e.g. via DNS spoofing or cache poisoning. (Note that an active attack is a circumstance where you may need to quickly switch bastion hosts, e.g. because the attacker has taken one down or you have taken it down in case it was compromised. In this circumstance you might need to deploy to production to fix an exploit or rotate keys, etc.) When you run `ob deploy` later it will rely on the saved verification in this step.
@@ -234,6 +236,26 @@ ob deploy push
235At this point you are done. Your app will be accessible at `${ROUTE}`. The currently deployed version - the git commit hash of the source repo - can be found at `${ROUTE}/version`.
237At this point you are done. Your app will be accessible at `${ROUTE}`. The currently deployed version - the git commit hash of the source repo - can be found at `${ROUTE}/version`.
239+### Custom Non-EC2 Deployment
241+By default Obelisk deployments are configured for NixOS machines running on AWS EC2. To provide your own configuration, you need to write a custom `module.nix` in the deployment repository. This still requires that your server is running NixOS.
243+`module.nix` must contain a Nix *function* that produces a [NixOS module function](https://nixos.org/nixos/manual/index.html#sec-writing-modules). The top-level function takes deployment configuration as arguments: `hostName`, `adminEmail`, `routeHost`, `enableHttps`, `version`, `exe`, `nixosPkgs`. Most of these are the values you specified during `ob deploy init` and are stored in the deployment repository. `version` is a `git` hash for the app that you're deploying. `exe` is the Linux build of the app (as seen in [Deploying Locally](#locally)). `nixosPkgs` is the package set used to construct the NixOS VM.
245+The [VirtualBox Deployment](#virtualbox-deployment) section provides an example.
247+#### VirtualBox Deployment
249+Here's a `module.nix` that is configured for deployment to a VirtualBox VM (running NixOS):
252+{ nixosPkgs, ... }: {...}: {
253+ imports = [ (nixosPkgs.path + /nixos/modules/virtualisation/virtualbox-image.nix) ];
257+The `{...}:` and following is the [NixOS module](https://nixos.org/nixos/manual/index.html#sec-writing-modules) definition.
237### From macOS
259### From macOS
239Deploying from macOS requires some extra setup:
261Deploying from macOS requires some extra setup:
@@ -247,7 +269,7 @@ Running `ob deploy push` will give you additional setup instructions.
248If 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:
270If 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:
251cd ~/code/myapp-deploy
273cd ~/code/myapp-deploy
252ob deploy update
274ob deploy update
253ob deploy push
275ob deploy push
@@ -273,14 +295,14 @@ These versions will work out of the box but iOS SDKs prior to 11.3 should also w
274More recent Xcodes should also work, as long as one of the SDKs mentioned above has been used.
296More recent Xcodes should also work, as long as one of the SDKs mentioned above has been used.
275To add another SDK to your current Xcode, [download](https://developer.apple.com/download/more/) the corresponding Xcode, extract it and copy its SDK folder next to the installed one, e.g.
297To add another SDK to your current Xcode, [download](https://developer.apple.com/download/more/) the corresponding Xcode, extract it and copy its SDK folder next to the installed one, e.g.
277open -W Xcode_9.2.xip
299open -W Xcode_9.2.xip
278sudo cp -R Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk
300sudo cp -R Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk
282You can verify that you have correct versions by running
304You can verify that you have correct versions by running
284xcodebuild -showsdks
306xcodebuild -showsdks
@@ -306,7 +328,7 @@ Ensure that `bundleIdentifier` matches the App ID of the development profile, or
3061. Connect the registered iPhone.
3281. Connect the registered iPhone.
3071. Find your Apple Team ID in the [developer portal](https://developer.apple.com/account/#/membership).
3291. Find your Apple Team ID in the [developer portal](https://developer.apple.com/account/#/membership).
3081. Run the deploy command with your Team ID:
3301. Run the deploy command with your Team ID:
310result-ios/bin/deploy [TEAM_ID]
332result-ios/bin/deploy [TEAM_ID]
311# or in debug mode via lldb:
333# or in debug mode via lldb:
312result-ios/bin/deploy [TEAM_ID] -d
334result-ios/bin/deploy [TEAM_ID] -d
@@ -316,7 +338,7 @@ result-ios/bin/deploy [TEAM_ID] -d
3161. Go to [developer portal - distribution profiles](https://developer.apple.com/account/ios/profile/production).
3381. Go to [developer portal - distribution profiles](https://developer.apple.com/account/ios/profile/production).
317Create and download a distribution profile.
339Create and download a distribution profile.
3181. Run the package script with your TEAM ID and your distribution profile to create a `.ipa`:
3401. Run the package script with your TEAM ID and your distribution profile to create a `.ipa`:
320result-ios/bin/package [TEAM_ID] /path/to/output/.ipa /path/to/profile/file
342result-ios/bin/package [TEAM_ID] /path/to/output/.ipa /path/to/profile/file