Supported versions
You can select the major and minor version. Patch versions are applied periodically for bug fixes and the like. When you deploy your app, you always get the latest available patches.Specify the language
To use Elixir, specifyelixir as your app’s type:
For example:
Built-in variables
Upsun exposes relationships and other configuration as environment variables. Most notably, it allows a program to determine at runtime what HTTP port it should listen on and what the credentials are to access other services. To get thePORT environment variable (the port on which your web application is supposed to listen) you would:
PLATFORM_RELATIONSHIPS environment variable in the section below.)
Tip
Rememberconfig/prod.exs is evaluated at build time and has no access to runtime configuration. Use config/releases.exs to configure your runtime environment.Building and running the application
If you are using Hex to manage your dependencies, you need to specify theMIX_ENV environment variable:
The SECRET_KEY_BASE variable is generated automatically based on the PLATFORM_PROJECT_ENTROPY variable.
You can change it.
Include in your build hook the steps to retrieve a local Hex and rebar, and then run mix do deps.get, deps.compile, compile on your application to build a binary.
That build hook works for most cases and assumes that your
mix.exs file is located at your app root.mix.exs is present at your app root and your build hook matches the above,
you can then start it from the web.commands.start directive.
The following basic app configuration is sufficient to run most Elixir applications.
Note that there is still an Nginx proxy server sitting in front of your application. If desired, certain paths may be served directly by Nginx without hitting your application (for static files, primarily) or you may route all requests to the Elixir application unconditionally, as in the example above.
Dependencies
The recommended way to handle Elixir dependencies on Upsun is using Hex. You can commit amix.exs file in your repository and the system downloads the dependencies in your deps section using the build hook above.
Accessing Services
Accessing Services Manually
The services configuration is available in the environment variablePLATFORM_RELATIONSHIPS.
Given a relationship defined in .upsun/config.yaml:
Assuming you have in mix.exs the Poison library to parse JSON:
ecto you could put in config/config.exs:
.upsun/config.yaml
View application instance details
To understand how an application’s instances are distributed, you can view the instance details in the project’s/run/peers.json file. To learn more, see View application instance details in the “Resource configuration” topic.