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.Ruby
Specify the language
To use Ruby, specifyruby as your app’s type:
For example:
Puma based Rails configuration
This example uses Puma to run a Ruby application. You could use any Ruby application server such as Unicorn. Configure the.upsun/config.yaml file with a few key settings as listed below.
A complete example is included at the end of this section.
- Specify the language of your application (available versions are listed above):
- Setup environment variables. Rails runs by default on a preview environment. You can change the Rails/Bundler via those environment variables, some of which are defaults on Upsun.
SECRET_KEY_BASE variable is generated automatically based on the
PLATFORM_PROJECT_ENTROPY
variable but you can change it.
Based on TARGET_RUBY_VERSION, we recommand to set on your Gemfile so next
PATCH release of ruby doesn’t fail the build:
-
Build your application with the build hook.
Assuming you have your dependencies stored in the
Gemfileat your app root, create a hook like the following:
dependencies key to install global dependencies.
These can be Ruby, Python, NodeJS, or PHP libraries.
If you have assets, it’s likely that you need NodeJS/yarn.
- Configure the command to start serving your application (this must be a foreground-running process) under the
websection:
- Define the web locations your application is using:
/static
to serve static files stored in /app/static/ folder.
Everything else is forwarded to your application server.
- Create any Read/Write mounts. The root file system is read only. You must explicitly describe writable mounts.
/app/tmp,
logs stored in /app/log, and active storage in /app/storage.
You can define other read/write mounts (your application code itself being deployed to a read-only file system).
Note that the file system is persistent and when you backup your cluster these mounts are also backed up.
-
Then, setup the routes to your application in
.upsun/config.yaml..upsun/config.yaml
Complete app configuration
Here is a complete.upsun/config.yaml file:
Configuring services
This example assumes there is a MySQL instance. To configure it, create a service such as the following:Connecting to services
Once you have a service, link to it in your app configuration: By using the following Ruby function calls, you can obtain the database details.config/database.yml with the values found with the snippet provided before.
Other tips
-
To speed up boot you can use the Bootsnap gem
and configure it with the local
/tmp:config/boot.rb - For garbage collection tuning, you can read this article and look for discourse configurations
-
New images are released on a regular basis to apply security patches. While the minor version will not change (as you are specifying it in the
typeproperty), the patch version will be updated. You may encounter this kind of error:To avoid issues when such updates are performed, usein yourGemfile, whereTARGET_RUBY_VERSIONhas been defined as above.
Troubleshooting
By default, deployments haveBUNDLE_DEPLOYMENT=1 to ensure projects have a Gemfile.lock file.
This is safer for version yank issues and other version upgrade breakages.
You may encounter an error like the following during a build:
- Run
bundle installwith the samerubyandbundlerversions defined in your.upsun/config.yamlfile. - Push the
Gemfile.lockto your repository.