# Deployment

## Using without Releases

It's recommended to create an escript or mix task to perform the
Realbook operations.  Guidelines for this process will be forthcoming.

## Deployment using Mix Releases

### With scripts in a generic location.

0. Create an entrypoint function (e.g. `MyApp.go/1`).  Let's say
  this function takes the `:script_dir` as a parameter and sets that
  application, then launches the script(s)
1. Upload your scripts (and assets) to your provisioning server (for
  example `~/my_scripts`)
2. Perform a release and transfer your application to the provisioning
  server.
3. Execute the realbooks.
  ```bash
  > path/to/release/my_app eval 'MyApp.go "~/my_scripts"'
  ```

### With scripts and assets in the priv/ directory

0. store your scripts and assets in, for example `priv/scripts` and `priv/assets`
1. create an entrypoint function that sets `:script_dir` as follows:
  ```elixir
  script_dir = :my_app
  |> :code.priv_dir
  |> Path.join("scripts")
  Application.put_env(:realbook, :script_dir, script_dir)
  ```

2. repeat with `:assets_dir`
3. Perform a release and transfer the application to the provisioning
  server.
4. Execute the realbooks.
  ```bash
  > path/to/release/my_app eval 'MyApp.go'
  ```

The advantage to the latter method is that it allows you to package your
scripts with your deployment.  If for some reason you want to keep them
separate, (for example, if they are shared in a repo between multiple
projects) then you should use the former method.
