Deploy a JavaScript Shopping Cart example


The main steps required to deploy a stateful application include:

  • Deploying required services

    To do this, Akka Serverless needs access to the container image registry hosting the packaged services. For this example, we give you access to a pre-built and packaged version of the example that is published in Lightbend’s registry.

  • Exposing the services for external access

    In the case of the Shopping Cart example, this provides HTTP access to the frontend and shopping cart services.

Watch this video to get a preview of the example app:


Deploy the packaged Shopping Cart application by following these steps:

  1. In a command or terminal window, if you haven’t authorized akkasls, enter the following command:

    akkasls auth login
  2. If you are not logged in, log in.

  3. Click Authorize.

    The akkasls prompt should return, confirming you are now authorized.

  4. Create a Shopping Cart project:

    akkasls projects new shopping-cart-js "Shopping Cart Sample(JS)"

    The project will not be active until you receive an email approving it.

  5. After you receive the approval email, list your projects:

    akkasls projects list

    The output should look similar to the following, of course with a different ID:

    NAME                   DESCRIPTION            STATUS   ID
    shopping-cart-js   Shopping Cart Sample(JS)   active   54b7757f-4f22-494f-9ffc-5bbfcec28088
  6. Set your project to be the current Akka Serverless project:

    akkasls config set project shopping-cart-js

    Now subsequent commands will apply to the Shopping Cart project.

  7. Copy and paste the following to deploy the shopping-cart service:

    akkasls svc deploy \
        shopping-cart \
  8. Verify the status of the shopping-cart service:

    akkasls svc list

  9. When the shopping-cart service status is Ready, expose the shopping-cart service with CORS header support:

    akkasls svc expose shopping-cart --enable-cors

    A message similar to the following displays: Service 'shopping-cart' was successfully exposed at:

  10. Copy the hostname on which the shopping-cart was exposed.

  11. Navigate to the statically hosted web UI:

  12. When prompted, enter the hostname you copied earlier.

You should now see the running shopping cart application.

Verify Stateful Service

Check if the shopping cart service is stateful in UI

  1. Enter any user name in the UI.

  2. Add items to your cart.

  3. Click the shopping cart to view the items you added.

  4. Close the browser.

  5. Open the browser again with the shopping cart URL.

  6. Enter the same user name, which connects to our stateful service.

  7. Click the shopping cart.

All of the items you added before closing the browser should still be there, showing that the service is stateful!


To learn how to create this example, see Tutorial: Create a shopping cart with Node.js.