Deploy your app to the cloud

Contents

It’s time for the final act - sign up for a free account and deploy your app on a live server.

Public API

So far, you’ve been playing with the API via Content Studio. If you want to access the API endpoint directly on your sandbo, it’s available at respectively:

  • http://localhost:8080/site/intro/draft (draft items)

  • http://localhost:8080/site/intro/master (published items)

In the following steps, you will deploy the API to a live URL. Remember, the GraphQL API is accessed via HTTP POST method, as such - visiting via a regular browser will give you a 404 error.

The Chrome extension Altair lets you browse any GraphQL API, simply by pointing it to the API URL.

Sign up

To complete this step, you’ll need Enonic XP running on a server. To get the job don, we’ll use Enonic’s free hosting tier:

If you are looking for other hosting options, Enonic XP is open source, and can be deployed pretty much anywhere.

  1. Visit our sign up for to claim your forever-free account.

  2. After signing up, complete the verification of your e-mail before you can move to the next step.

  3. Log in to the Enonic Console and choose your account name.

Choose your account name

Create solution

  1. then create a new solution from the menu: Solutions → Essentials → Create. Complete the solution wizard steps using your personal preferences.

Select the 'Essentials' template

We will then spin up an Enonic XP environment, similar to your local sandbox but this time on a real server in the Cloud.

Deploy application

  1. Once the solution has started (verify by logging in to the XP admin), you need to authorize the CLI. Run this command:

    enonic cloud login
  2. After successful authentication install your app using this command:

    enonic cloud app install
    You must execute this command from your app folder.
    Alternatively upload the app from the Console directly: Solutions → <Your solution> → Applications → Install. The app file can be found in your project folder i.e. build/libs/myapp.jar.

Once installed, the app should be listed in the Cloud console:

List of applications including 'MyApp'

Explose the API

Finally, you may also want to expose the API:

  1. create an ingress in the Enonic Cloud console: Solutions → <Your solution> → Ingresses → Create. Give it a suitable name i.e. Intro API, and use the following values:

    Environment

    Use the default value

    Target

    /site/intro

    Domain

    Use the default value

    Path

    /api

    ID provider

    leave empty

  2. Once the incress is created, Select it in the list. This will reveal a link to your API on the right. hand side

  3. Visit the URL to see the Query Playground API browser.

    The API browser can be disabled by changing the configuration of the Guillotine app.

    To use the published content API directly from a GraphQL client, simply add append /master to the Ingress URL.

    Remember, the GraphQL API only accepts POST requests, so the browser will only show a 404 at this point.

Dive deeper

🎉 Awesome! You made it to the end.

In the process, you created an Enonic XP sandbox, built and customized your own app, ran GraphQL queries, got to know the Enonic CLI and our SaaS service.

As you may already imagine, the Platform is capable of so much more. Did you for instance know that Enonic has a JavaScript framework, complete with TypeScript definitions the entire platform API? You may use it in your apps to extend and customize the Platform as you like.

To continue the journey, we recommend visiting the Enonic tutorials section of the Developer Portal.

Bon voyage!


Contents

Contents