Getting Started Guide¶
The goal of this guide is to get your app up and running on Gigalixir. You will sign up for an account, prepare your app, deploy, and provision a database.
If you’re deploying an open source project, we provide consulting services free of charge. Contact us and we’ll send you a pull request with everything you need to get started.
Install the Command-Line Interface¶
Next, install the command-line interface. Gigalixir has a web interface at https://console.gigalixir.com/, but you will likely still want the CLI.
Verify by running
Create an Account¶
If you already have an account, skip this step.
Create an account using the following command. It will prompt you for your email address and password. You will have to confirm your email before continuing. Gigalixir’s free tier does not require a credit card, but you will be limited to 1 instance with 0.2GB of memory and 1 postgresql database limited to 10,000 rows.
Next, log in. This will grant you an api key. It will also optionally modify your ~/.netrc file so that all future commands are authenticated.
Verify by running
Prepare Your App¶
Most likely, there is nothing you need to do here and you can skip this step and “just deploy”, but it depends on what version of phoenix you’re running and whether you are okay running in mix mode without distillery or elixir releases.
For more information, click here: Modifying an Existing App to Run on Gigalixir.
Or if you just want to give gigalixir a spin, clone our reference app.
git clone https://github.com/gigalixir/gigalixir-getting-started.git
Set Up App for Deploys¶
To create your app, run the following command. It will also set up a git remote. This must be run from within a git repository folder. An app name will be generated for you, but you can also optionally supply an app name if you wish using
gigalixir create -n $APP_NAME. There is currently no way to change your app name once it is created. If you like, you can also choose which cloud provider and region using the
--region options. We currently support
us-west-2. The default is v2018-us-central1 on gcp.
cd gigalixir-getting-started APP_NAME=$(gigalixir create)
Verify that the app was created, by running
Verify that a git remote was created by running
git remote -v
If someone in your organization has already created the gigalixir app and you only need to add the proper git remote to your local repository configuration, you can skip the app creation and add a the
gigalixir git remote by using the
gigalixir git:remote $app
The default Elixir version is defined here which is quite old and it’s a good idea to use the same version in production as you use in development so let’s specify them. Supported Elixir and erlang versions can be found at https://github.com/HashNuke/heroku-buildpack-elixir#version-support
echo "elixir_version=1.11.3" > elixir_buildpack.config echo "erlang_version=23.2" >> elixir_buildpack.config
Same for nodejs
echo "node_version=14.15.4" > phoenix_static_buildpack.config
Don’t forget to commit
git add elixir_buildpack.config phoenix_static_buildpack.config git commit -m "set elixir, erlang, and node version"
Provision a Database¶
Phoenix 1.4+ enforces the DATABASE_URL env var at compile time so let’s create a database first, before deploying.
gigalixir pg:create --free
Verify by running
Once the database is created, verify your configuration includes a
DATABASE_URL by running
Finally, build and deploy.
git push gigalixir
Wait a minute or two for the app to pass health checks. You can check the status by running
Once it’s healthy, verify it works
curl https://$APP_NAME.gigalixirapp.com/ # or you could also run # gigalixir open
If you are not using releases, the easiest way to run migrations is as a job.
gigalixir run mix ecto.migrate # this is run asynchronously as a job, so to see the progress, you need to run gigalixir logs
If you are using distillery or Elixir releases, your app needs to be up and running, then run
# pg:migrate runs migrations from your app node so we need to add ssh keys first gigalixir account:ssh_keys:add "$(cat ~/.ssh/id_rsa.pub)" gigalixir ps:migrate
For more, see How to Run Migrations.