Create Harmony Platform

You can create a new Harmony platform using the following command:

bit create harmony-platform wayne-platform
CopiedCopy

Run the platform:

bit run wayne-platform
CopiedCopy
Compose Harmony Platforms using different domain components
Compose Harmony Platforms using different domain components

Platform composition

Harmony platforms are used to compose, run and deploy a platform composed from Aspects:

import { HarmonyPlatform } from '@bitdev/harmony.harmony-platform';
import { BrowserRuntime } from '@bitdev/harmony.runtimes.browser-runtime';
import { NodeJSRuntime } from '@bitdev/harmony.runtimes.nodejs-runtime';
import { PeopleAspect } from '@bitdev/harmony.examples.people';
import { WaynePlatformAspect } from '@bitdev/harmony.examples.wayne-platform';

/**
 * compose the wayne.com platform.
 */    
export const WayneCom = HarmonyPlatform.from({
  name: 'wayne-com',

  /**
   * platform aspect to compose.
   */
  platform: [WaynePlatformAspect],

  runtimes: [
    new BrowserRuntime(),
    new NodeJSRuntime()
  ],

  aspects: [
    PeopleAspect,
  ],
});

export default WayneCom;
CopiedCopy

Platform Aspect

You can use the platform property key to set the entry Aspect for your platform as demonstrated above. Platform Aspects are mandatory in Harmony platforms and used as the gateway to your platform.

bit create platform-aspect wayne-platform
CopiedCopy

Learn more on Platform Aspects.

Aspects

Aspects are used to stitch a composable architecture into a Platform pluggable components. They encapsulate the logic required to plugin a certain functionallity to a platform including its backend, frontend and other required runtimes.

You can create new Aspects to stitch your composable architecutre:

bit create aspect billing
CopiedCopy

To learn more on building aspects, head to the Harmony Aspects section.

Runtimes

Harmony platform can run at various platforms. By default, when running an Harmony platform it runs all runtimes defined the in the platform using the runtimes property as demonstrated above.

You can run specific runtimes of your harmony platform using the following command:

bit run wayne-com -- ui,node
CopiedCopy

You can use the existing Harmony runtimes, or build new runtimes as needed.

Build

When using the official runtimes, upon every snap or tag of your components, a new build would trigger and Ripple CI would build your platform, producing a single unified artifact for each runtime.

You can customize the build or add your own steps as needed by using the build property key in your Harmony platform, referencing it to a build function:

import { HarmonyBuildContext } from '@bitdev/harmony.harmony-platform';

export async function platformBuildFunction(context: HarmonyBuildContext) {
  console.log(context.capsule.path, context.aspects); // echos the platform path and a map aspects composed into the platform.

  return {
    artifacts: []
  }
}
CopiedCopy

Find more information on the API available on the build context provided by Harmony. To learn further into the Application context head to the Building apps section.

You can use the following command to test your build:

bit build wayne-com
CopiedCopy

Head to the your component directory in the output build root to see your articats.

Our official runtimes produce a artifacts for NodeJS, and the Browser runtimes using ESBuild for performance and Webpack for compatability.

Deploy

Using Harmony and Ripple CI your platform produces unified build artifact for each of your runtimes, which results in faster performance but also ease deployment and portability of your platform. Using Ripple CI builds are always preserved fast, and teams can independently preview and release their changes to production.

You can use our official Kubernetes deployer to deploy and orchestrate your platform on a kubernetes cluster. To use that, install and compose the Kubernetes aspect to your Harmony platform:

import { KubernetesAspect } from '@bitdev/symphony.deployers.kubernetes';
import { SymphonyPlatformAspect } from '@bitdev/symphony.symphony-platform';

/**
 * compose the platform.
 */
export const MyPlatform = HarmonyPlatform.from({
  name: 'my-platform',
  platform: SymphonyPlatformAspect,
  
  aspects: [[
    KubernetesAspect, {
      auth: {
        // kubernetes connection string.
        basic: {
          server: 'https://1.2.3.4',
          certificate: process.env.KUBE_CERTIFICATE_AUTHORITY_DATA,
          token: process.env.KUBE_USER_TOKEN
        }
      },
      // docker registry configuration
      docker: {
        imagePrefix: 'dockerhub-account'
        username: 'ci-user',
        password: process.env.DOCKERHUB_PASSWORD,
      }
  }]],
});
CopiedCopy

Alternatively, you can implement your own deploy function using the deploy property key in your Harmony platform:

// my-platform.bit-app.ts
import { HarmonyDeployContext } from '@bitdev/harmony.harmony-platform';

export async function platformBuildFunction(context: HarmonyDeployContext) {
  // echos the platform path and a list of build artifacts created for each of the platform runtimes.
  console.log(context.capsule.path, context.runtimeArtifacts); 

  return {
    // used for display on bit cloud for staging and production environments.
    url: 'my-platform.com'
  }
}
CopiedCopy

You can find more information on the API available in the Harmony Deploy Context API reference. To learn further into the Application context head to the Deploying apps section.

You can test your deployment using the following command (keep caution):

bit build --include-tag
CopiedCopy

To deploy a micro service a common practice is to invoke the NodeJS runtime with a deploy argument and handle deployment from within the platform aspect.

Learn more