+ Swiss PaaS +

Gleis documentation

Getting started

Install the Gleis CLI

  1. Install the Gleis CLI gem: gem install gleis

Get a Gleis account

  1. You can get yourself a Gleis account by contacting us or by using the Gleis CLI gem directly: gleis register name@company.ch We will take care of the rest.

Using Gleis for the first time

  1. Log in to Gleis: gleis login name@company.ch
  2. As soon as you are logged in for the first time, your Gleis SSH public/private key pair will be generated.
  3. Enter a passphrase for your new SSH key (optional, but recommended).

Configure Git

  1. Configure your local Git author name and e-mail address, unless you are planning to use your global settings: git config user.name "First Last"
    $ git config user.email name@company.ch
  2. Initialise Git repository: git init

Ruby on Rails app deployment

Create and deploy your app on Gleis

  1. Inside your terminal, move to your app's root directory: cd path/to/my_rails_app
  2. Install gems and build your Gemfile.lock file: bundle install
  3. Log in to Gleis: gleis login name@company.ch Type in your password, when prompted.
  4. Create a new Gleis app: gleis app create
  5. Commit to Git: git commit -am "initial commit"
  6. Deploy your app by pushing it to Gleis Git: git push gleis master

Re-deploying your app after making modifications

  1. If you've added any new gems to your Gemfile, do not forget to rebuild your Gemfile.lock, by running: bundle install
  2. Commit your changes to your local Git repository: git commit -am "my modifications"
  3. Push to Gleis for re-deployment: git push gleis master

Deploying on Gleis directly from Travis CI

Deploying your Gleis app directly from your Travis CI pipeline is supported and is as simple as adding the right configuration parameters to your project's .travis.yml file. Your app will be automatically deployed to Gleis, upon a successful build in Travis CI.

  1. First, generate an encrypted version of your Gleis password to be used with Travis CI: travis encrypt my_gleis_password
  2. Add a new "deploy" block in your .travis.yml file with your username, app name and encrypted password from the previous step. deploy: provider: gleis username: my_email_address password: secure: "travis_encrypted_password" app: my_app_name
  3. You can now push your changes to your GitHub repository and profit from automatic deployments to Gleis.

Additional options

Ruby versions

  1. Gleis supports all stable Ruby versions (2.3—2.5). Specify the version required by your app in the .ruby-version file or run: rbenv local my_ruby_version

Setting environment variables

  1. Optionally, you can configure environment variables.
    In the following example, we are setting an environment variable that holds the key for an API. gleis app config API_KEY=my_api_key

Using Databases

  1. Create a database: gleis db new
  2. Promote database; this will set this specific database as the app's default.
    Note: If you only have one database, then this will be automatically promoted and there is no need to run the following command. gleis db promote DATABASE1_URL
  3. Install any pending migrations: gleis app exec "bundle exec rails db:migrate"
  4. Optional: Seed database: gleis app exec "bundle exec rails db:seed"

Using persistent storage

  1. You can optionally add persistent storage for those files that are not checked out in the Git repository. Typically, these would be file uploads, such as photos, PDF files etc. gleis storage add dfs
  2. You will need to attach the persistent storage to a specific directory. In the following example, we are mounting our persistent storage to a directory called "system", found inside our app's "public" directory. gleis storage attach /usr/src/app/public/system